| 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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 // Every |check_expiration_count| call to either SetSSLSession() or | 110 // Every |check_expiration_count| call to either SetSSLSession() or |
| 111 // SetSSLSessionWithKey() triggers a check for, and removal of, expired | 111 // SetSSLSessionWithKey() triggers a check for, and removal of, expired |
| 112 // sessions. | 112 // sessions. |
| 113 // | 113 // |
| 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 | |
| 121 // added to the cache. | |
| 122 void SetSessionAddedCallback(SSL* ssl, const base::Closure& callback); | |
| 123 | |
| 124 // Removes the entry for |ssl| from cache's callback map. | |
| 125 void RemoveSessionAddedCallback(SSL* ssl); | |
| 126 | |
| 127 // Indicates that the SSL session associated with |ssl| is "good" - that is, | 120 // Indicates that the SSL session associated with |ssl| is "good" - that is, |
| 128 // that all associated cryptographic parameters that were negotiated, | 121 // that all associated cryptographic parameters that were negotiated, |
| 129 // including the peer's certificate, were successfully validated. Because | 122 // including the peer's certificate, were successfully validated. Because |
| 130 // OpenSSL does not provide an asynchronous certificate verification | 123 // OpenSSL does not provide an asynchronous certificate verification |
| 131 // callback, it's necessary to manually manage the sessions to ensure that | 124 // callback, it's necessary to manually manage the sessions to ensure that |
| 132 // only validated sessions are resumed. | 125 // only validated sessions are resumed. |
| 133 void MarkSSLSessionAsGood(SSL* ssl); | 126 void MarkSSLSessionAsGood(SSL* ssl); |
| 134 | 127 |
| 128 // Returns true if the SSL session associated with |ssl| has been marked as |
| 129 // good. |
| 130 bool SessionIsGood(SSL* ssl); |
| 131 |
| 135 // Flush removes all entries from the cache. This is typically called when | 132 // Flush removes all entries from the cache. This is typically called when |
| 136 // the system's certificate store has changed. | 133 // the system's certificate store has changed. |
| 137 void Flush(); | 134 void Flush(); |
| 138 | 135 |
| 139 // TODO(digit): Move to client code. | 136 // TODO(digit): Move to client code. |
| 140 static const int kDefaultTimeoutSeconds = 60 * 60; | 137 static const int kDefaultTimeoutSeconds = 60 * 60; |
| 141 static const size_t kMaxEntries = 1024; | 138 static const size_t kMaxEntries = 1024; |
| 142 static const size_t kMaxExpirationChecks = 256; | 139 static const size_t kMaxExpirationChecks = 256; |
| 143 | 140 |
| 144 private: | 141 private: |
| 145 DISALLOW_COPY_AND_ASSIGN(SSLSessionCacheOpenSSL); | 142 DISALLOW_COPY_AND_ASSIGN(SSLSessionCacheOpenSSL); |
| 146 | 143 |
| 147 SSLSessionCacheOpenSSLImpl* impl_; | 144 SSLSessionCacheOpenSSLImpl* impl_; |
| 148 }; | 145 }; |
| 149 | 146 |
| 150 } // namespace net | 147 } // namespace net |
| 151 | 148 |
| 152 #endif // NET_SOCKET_SSL_SESSION_CACHE_OPENSSL_H | 149 #endif // NET_SOCKET_SSL_SESSION_CACHE_OPENSSL_H |
| OLD | NEW |