| 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" |
| 11 #include "base/callback_forward.h" |
| 11 #include "net/base/net_export.h" | 12 #include "net/base/net_export.h" |
| 12 | 13 |
| 13 // Avoid including OpenSSL headers here. | 14 // Avoid including OpenSSL headers here. |
| 14 typedef struct ssl_ctx_st SSL_CTX; | 15 typedef struct ssl_ctx_st SSL_CTX; |
| 15 typedef struct ssl_st SSL; | 16 typedef struct ssl_st SSL; |
| 16 | 17 |
| 17 namespace net { | 18 namespace net { |
| 18 | 19 |
| 19 class SSLSessionCacheOpenSSLImpl; | 20 class SSLSessionCacheOpenSSLImpl; |
| 20 | 21 |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 // ensure that the value of |cache_key| matches the result of calling the | 107 // ensure that the value of |cache_key| matches the result of calling the |
| 107 // configuration's |key_func| function with the |ssl| as parameter. | 108 // configuration's |key_func| function with the |ssl| as parameter. |
| 108 // | 109 // |
| 109 // Every |check_expiration_count| call to either SetSSLSession() or | 110 // Every |check_expiration_count| call to either SetSSLSession() or |
| 110 // SetSSLSessionWithKey() triggers a check for, and removal of, expired | 111 // SetSSLSessionWithKey() triggers a check for, and removal of, expired |
| 111 // sessions. | 112 // sessions. |
| 112 // | 113 // |
| 113 // 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. |
| 114 bool SetSSLSessionWithKey(SSL* ssl, const std::string& cache_key); | 115 bool SetSSLSessionWithKey(SSL* ssl, const std::string& cache_key); |
| 115 | 116 |
| 117 // Return true iff a cached session was associated with the given |cache_key|. |
| 118 bool SSLSessionIsInCache(const std::string& cache_key) const; |
| 119 |
| 120 // Informs the cache that it should run a callback when |ssl|'s |
| 121 // session is 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 |
| 116 // Indicates that the SSL session associated with |ssl| is "good" - that is, | 127 // Indicates that the SSL session associated with |ssl| is "good" - that is, |
| 117 // that all associated cryptographic parameters that were negotiated, | 128 // that all associated cryptographic parameters that were negotiated, |
| 118 // including the peer's certificate, were successfully validated. Because | 129 // including the peer's certificate, were successfully validated. Because |
| 119 // OpenSSL does not provide an asynchronous certificate verification | 130 // OpenSSL does not provide an asynchronous certificate verification |
| 120 // callback, it's necessary to manually manage the sessions to ensure that | 131 // callback, it's necessary to manually manage the sessions to ensure that |
| 121 // only validated sessions are resumed. | 132 // only validated sessions are resumed. |
| 122 void MarkSSLSessionAsGood(SSL* ssl); | 133 void MarkSSLSessionAsGood(SSL* ssl); |
| 123 | 134 |
| 124 // Flush removes all entries from the cache. This is typically called when | 135 // Flush removes all entries from the cache. This is typically called when |
| 125 // the system's certificate store has changed. | 136 // the system's certificate store has changed. |
| 126 void Flush(); | 137 void Flush(); |
| 127 | 138 |
| 128 // TODO(digit): Move to client code. | 139 // TODO(digit): Move to client code. |
| 129 static const int kDefaultTimeoutSeconds = 60 * 60; | 140 static const int kDefaultTimeoutSeconds = 60 * 60; |
| 130 static const size_t kMaxEntries = 1024; | 141 static const size_t kMaxEntries = 1024; |
| 131 static const size_t kMaxExpirationChecks = 256; | 142 static const size_t kMaxExpirationChecks = 256; |
| 132 | 143 |
| 133 private: | 144 private: |
| 134 DISALLOW_COPY_AND_ASSIGN(SSLSessionCacheOpenSSL); | 145 DISALLOW_COPY_AND_ASSIGN(SSLSessionCacheOpenSSL); |
| 135 | 146 |
| 136 SSLSessionCacheOpenSSLImpl* impl_; | 147 SSLSessionCacheOpenSSLImpl* impl_; |
| 137 }; | 148 }; |
| 138 | 149 |
| 139 } // namespace net | 150 } // namespace net |
| 140 | 151 |
| 141 #endif // NET_SOCKET_SSL_SESSION_CACHE_OPENSSL_H | 152 #endif // NET_SOCKET_SSL_SESSION_CACHE_OPENSSL_H |
| OLD | NEW |