| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 class OpenSSLAdapter : public SSLAdapter, public MessageHandler { | 31 class OpenSSLAdapter : public SSLAdapter, public MessageHandler { |
| 32 public: | 32 public: |
| 33 static bool InitializeSSL(VerificationCallback callback); | 33 static bool InitializeSSL(VerificationCallback callback); |
| 34 static bool InitializeSSLThread(); | 34 static bool InitializeSSLThread(); |
| 35 static bool CleanupSSL(); | 35 static bool CleanupSSL(); |
| 36 | 36 |
| 37 explicit OpenSSLAdapter(AsyncSocket* socket, | 37 explicit OpenSSLAdapter(AsyncSocket* socket, |
| 38 OpenSSLAdapterFactory* factory = nullptr); | 38 OpenSSLAdapterFactory* factory = nullptr); |
| 39 ~OpenSSLAdapter() override; | 39 ~OpenSSLAdapter() override; |
| 40 | 40 |
| 41 void SetIgnoreBadCert(bool ignore) override; |
| 42 void SetAlpnProtocols(const std::vector<std::string>& protos) override; |
| 43 |
| 41 void SetMode(SSLMode mode) override; | 44 void SetMode(SSLMode mode) override; |
| 42 void SetIdentity(SSLIdentity* identity) override; | 45 void SetIdentity(SSLIdentity* identity) override; |
| 43 void SetRole(SSLRole role) override; | 46 void SetRole(SSLRole role) override; |
| 44 AsyncSocket* Accept(SocketAddress* paddr) override; | 47 AsyncSocket* Accept(SocketAddress* paddr) override; |
| 45 int StartSSL(const char* hostname, bool restartable) override; | 48 int StartSSL(const char* hostname, bool restartable) override; |
| 46 int Send(const void* pv, size_t cb) override; | 49 int Send(const void* pv, size_t cb) override; |
| 47 int SendTo(const void* pv, size_t cb, const SocketAddress& addr) override; | 50 int SendTo(const void* pv, size_t cb, const SocketAddress& addr) override; |
| 48 int Recv(void* pv, size_t cb, int64_t* timestamp) override; | 51 int Recv(void* pv, size_t cb, int64_t* timestamp) override; |
| 49 int RecvFrom(void* pv, | 52 int RecvFrom(void* pv, |
| 50 size_t cb, | 53 size_t cb, |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 // This buffer is used if SSL_write fails with SSL_ERROR_WANT_WRITE, which | 125 // This buffer is used if SSL_write fails with SSL_ERROR_WANT_WRITE, which |
| 123 // means we need to keep retrying with *the same exact data* until it | 126 // means we need to keep retrying with *the same exact data* until it |
| 124 // succeeds. Afterwards it will be cleared. | 127 // succeeds. Afterwards it will be cleared. |
| 125 Buffer pending_data_; | 128 Buffer pending_data_; |
| 126 | 129 |
| 127 SSL* ssl_; | 130 SSL* ssl_; |
| 128 SSL_CTX* ssl_ctx_; | 131 SSL_CTX* ssl_ctx_; |
| 129 std::string ssl_host_name_; | 132 std::string ssl_host_name_; |
| 130 // Do DTLS or not | 133 // Do DTLS or not |
| 131 SSLMode ssl_mode_; | 134 SSLMode ssl_mode_; |
| 135 // If true, the server certificate need not match the configured hostname. |
| 136 bool ignore_bad_cert_; |
| 137 // List of protocols to be used in the TLS ALPN extension. |
| 138 std::vector<std::string> alpn_protocols_; |
| 132 | 139 |
| 133 bool custom_verification_succeeded_; | 140 bool custom_verification_succeeded_; |
| 134 }; | 141 }; |
| 135 | 142 |
| 143 std::string TransformAlpnProtocols(const std::vector<std::string>& protos); |
| 144 |
| 145 ///////////////////////////////////////////////////////////////////////////// |
| 136 class OpenSSLAdapterFactory : public SSLAdapterFactory { | 146 class OpenSSLAdapterFactory : public SSLAdapterFactory { |
| 137 public: | 147 public: |
| 138 OpenSSLAdapterFactory(); | 148 OpenSSLAdapterFactory(); |
| 139 ~OpenSSLAdapterFactory() override; | 149 ~OpenSSLAdapterFactory() override; |
| 140 | 150 |
| 141 void SetMode(SSLMode mode) override; | 151 void SetMode(SSLMode mode) override; |
| 142 OpenSSLAdapter* CreateAdapter(AsyncSocket* socket) override; | 152 OpenSSLAdapter* CreateAdapter(AsyncSocket* socket) override; |
| 143 | 153 |
| 144 static OpenSSLAdapterFactory* Create(); | 154 static OpenSSLAdapterFactory* Create(); |
| 145 | 155 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 157 SSL_CTX* ssl_ctx_; | 167 SSL_CTX* ssl_ctx_; |
| 158 // Map of hostnames to SSL_SESSIONs; holds references to the SSL_SESSIONs, | 168 // Map of hostnames to SSL_SESSIONs; holds references to the SSL_SESSIONs, |
| 159 // which are cleaned up when the factory is destroyed. | 169 // which are cleaned up when the factory is destroyed. |
| 160 // TODO(juberti): Add LRU eviction to keep the cache from growing forever. | 170 // TODO(juberti): Add LRU eviction to keep the cache from growing forever. |
| 161 std::map<std::string, SSL_SESSION*> sessions_; | 171 std::map<std::string, SSL_SESSION*> sessions_; |
| 162 }; | 172 }; |
| 163 | 173 |
| 164 } // namespace rtc | 174 } // namespace rtc |
| 165 | 175 |
| 166 #endif // WEBRTC_RTC_BASE_OPENSSLADAPTER_H_ | 176 #endif // WEBRTC_RTC_BASE_OPENSSLADAPTER_H_ |
| OLD | NEW |