| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef NET_SOCKET_SSL_SESSION_CACHE_OPENSSL_H | 5 #ifndef NET_SOCKET_SSL_SESSION_CACHE_OPENSSL_H |
| 6 #define NET_SOCKET_SSL_SESSION_CACHE_OPENSSL_H | 6 #define NET_SOCKET_SSL_SESSION_CACHE_OPENSSL_H |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 // Return true iff a cached session was associated with the |ssl| connection. | 114 // Return true iff a cached session was associated with the |ssl| connection. |
| 115 bool SetSSLSessionWithKey(SSL* ssl, const std::string& cache_key); | 115 bool SetSSLSessionWithKey(SSL* ssl, const std::string& cache_key); |
| 116 | 116 |
| 117 // Return true iff a cached session was associated with the given |cache_key|. | 117 // Return true iff a cached session was associated with the given |cache_key|. |
| 118 bool SSLSessionIsInCache(const std::string& cache_key) const; | 118 bool SSLSessionIsInCache(const std::string& cache_key) const; |
| 119 | 119 |
| 120 // Informs the cache that it should run a callback when |ssl|'s session is | 120 // Informs the cache that it should run a callback when |ssl|'s session is |
| 121 // added to the cache. | 121 // added to the cache. |
| 122 void SetSessionAddedCallback(SSL* ssl, const base::Closure& callback); | 122 void SetSessionAddedCallback(SSL* ssl, const base::Closure& callback); |
| 123 | 123 |
| 124 // Determines if the session for |ssl| is in the cache, and calls the |
| 125 // appropriate callback if that is the case. |
| 126 void CheckIfSessionFinished(const SSL* ssl); |
| 127 |
| 124 // Removes the entry for |ssl| from cache's callback map. | 128 // Removes the entry for |ssl| from cache's callback map. |
| 125 void RemoveSessionAddedCallback(SSL* ssl); | 129 void RemoveSessionAddedCallback(SSL* ssl); |
| 126 | 130 |
| 127 // Indicates that the SSL session associated with |ssl| is "good" - that is, | 131 // Indicates that the SSL session associated with |ssl| is "good" - that is, |
| 128 // that all associated cryptographic parameters that were negotiated, | 132 // that all associated cryptographic parameters that were negotiated, |
| 129 // including the peer's certificate, were successfully validated. Because | 133 // including the peer's certificate, were successfully validated. Because |
| 130 // OpenSSL does not provide an asynchronous certificate verification | 134 // OpenSSL does not provide an asynchronous certificate verification |
| 131 // callback, it's necessary to manually manage the sessions to ensure that | 135 // callback, it's necessary to manually manage the sessions to ensure that |
| 132 // only validated sessions are resumed. | 136 // only validated sessions are resumed. |
| 133 void MarkSSLSessionAsGood(SSL* ssl); | 137 void MarkSSLSessionAsGood(SSL* ssl); |
| 134 | 138 |
| 135 // Flush removes all entries from the cache. This is typically called when | 139 // Flush removes all entries from the cache. This is typically called when |
| 136 // the system's certificate store has changed. | 140 // the system's certificate store has changed. |
| 137 void Flush(); | 141 void Flush(); |
| 138 | 142 |
| 139 // TODO(digit): Move to client code. | 143 // TODO(digit): Move to client code. |
| 140 static const int kDefaultTimeoutSeconds = 60 * 60; | 144 static const int kDefaultTimeoutSeconds = 60 * 60; |
| 141 static const size_t kMaxEntries = 1024; | 145 static const size_t kMaxEntries = 1024; |
| 142 static const size_t kMaxExpirationChecks = 256; | 146 static const size_t kMaxExpirationChecks = 256; |
| 143 | 147 |
| 144 private: | 148 private: |
| 145 DISALLOW_COPY_AND_ASSIGN(SSLSessionCacheOpenSSL); | 149 DISALLOW_COPY_AND_ASSIGN(SSLSessionCacheOpenSSL); |
| 146 | 150 |
| 147 SSLSessionCacheOpenSSLImpl* impl_; | 151 SSLSessionCacheOpenSSLImpl* impl_; |
| 148 }; | 152 }; |
| 149 | 153 |
| 150 } // namespace net | 154 } // namespace net |
| 151 | 155 |
| 152 #endif // NET_SOCKET_SSL_SESSION_CACHE_OPENSSL_H | 156 #endif // NET_SOCKET_SSL_SESSION_CACHE_OPENSSL_H |
| OLD | NEW |