Chromium Code Reviews| 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 "base/callback_forward.h" |
|
wtc
2014/08/07 20:04:04
Delete this.
| |
| 12 #include "net/base/net_export.h" | 12 #include "net/base/net_export.h" |
| 13 | 13 |
| 14 // Avoid including OpenSSL headers here. | 14 // Avoid including OpenSSL headers here. |
| 15 typedef struct ssl_ctx_st SSL_CTX; | 15 typedef struct ssl_ctx_st SSL_CTX; |
| 16 typedef struct ssl_st SSL; | 16 typedef struct ssl_st SSL; |
| 17 | 17 |
| 18 namespace net { | 18 namespace net { |
| 19 | 19 |
| 20 class SSLSessionCacheOpenSSLImpl; | 20 class SSLSessionCacheOpenSSLImpl; |
| 21 | 21 |
| (...skipping 88 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 |
| 135 // Flush removes all entries from the cache. This is typically called when | 128 // Flush removes all entries from the cache. This is typically called when |
| 136 // the system's certificate store has changed. | 129 // the system's certificate store has changed. |
| 137 void Flush(); | 130 void Flush(); |
| 138 | 131 |
| 139 // TODO(digit): Move to client code. | 132 // TODO(digit): Move to client code. |
| 140 static const int kDefaultTimeoutSeconds = 60 * 60; | 133 static const int kDefaultTimeoutSeconds = 60 * 60; |
| 141 static const size_t kMaxEntries = 1024; | 134 static const size_t kMaxEntries = 1024; |
| 142 static const size_t kMaxExpirationChecks = 256; | 135 static const size_t kMaxExpirationChecks = 256; |
| 143 | 136 |
| 144 private: | 137 private: |
| 145 DISALLOW_COPY_AND_ASSIGN(SSLSessionCacheOpenSSL); | 138 DISALLOW_COPY_AND_ASSIGN(SSLSessionCacheOpenSSL); |
| 146 | 139 |
| 147 SSLSessionCacheOpenSSLImpl* impl_; | 140 SSLSessionCacheOpenSSLImpl* impl_; |
| 148 }; | 141 }; |
| 149 | 142 |
| 150 } // namespace net | 143 } // namespace net |
| 151 | 144 |
| 152 #endif // NET_SOCKET_SSL_SESSION_CACHE_OPENSSL_H | 145 #endif // NET_SOCKET_SSL_SESSION_CACHE_OPENSSL_H |
| OLD | NEW |