| 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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 const uint8_t* context, | 100 const uint8_t* context, |
| 101 size_t context_len, | 101 size_t context_len, |
| 102 bool use_context, | 102 bool use_context, |
| 103 uint8_t* result, | 103 uint8_t* result, |
| 104 size_t result_len) override; | 104 size_t result_len) override; |
| 105 | 105 |
| 106 // DTLS-SRTP interface | 106 // DTLS-SRTP interface |
| 107 bool SetDtlsSrtpCryptoSuites(const std::vector<int>& crypto_suites) override; | 107 bool SetDtlsSrtpCryptoSuites(const std::vector<int>& crypto_suites) override; |
| 108 bool GetDtlsSrtpCryptoSuite(int* crypto_suite) override; | 108 bool GetDtlsSrtpCryptoSuite(int* crypto_suite) override; |
| 109 | 109 |
| 110 bool IsTlsConnected() override { return state_ == SSL_CONNECTED; } |
| 111 |
| 110 // Capabilities interfaces | 112 // Capabilities interfaces |
| 111 static bool HaveDtls(); | 113 static bool HaveDtls(); |
| 112 static bool HaveDtlsSrtp(); | 114 static bool HaveDtlsSrtp(); |
| 113 static bool HaveExporter(); | 115 static bool HaveExporter(); |
| 114 static bool IsBoringSsl(); | 116 static bool IsBoringSsl(); |
| 115 | 117 |
| 116 static bool IsAcceptableCipher(int cipher, KeyType key_type); | 118 static bool IsAcceptableCipher(int cipher, KeyType key_type); |
| 117 static bool IsAcceptableCipher(const std::string& cipher, KeyType key_type); | 119 static bool IsAcceptableCipher(const std::string& cipher, KeyType key_type); |
| 118 | 120 |
| 119 protected: | 121 protected: |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 | 160 |
| 159 // Override MessageHandler | 161 // Override MessageHandler |
| 160 void OnMessage(Message* msg) override; | 162 void OnMessage(Message* msg) override; |
| 161 | 163 |
| 162 // Flush the input buffers by reading left bytes (for DTLS) | 164 // Flush the input buffers by reading left bytes (for DTLS) |
| 163 void FlushInput(unsigned int left); | 165 void FlushInput(unsigned int left); |
| 164 | 166 |
| 165 // SSL library configuration | 167 // SSL library configuration |
| 166 SSL_CTX* SetupSSLContext(); | 168 SSL_CTX* SetupSSLContext(); |
| 167 // SSL verification check | 169 // SSL verification check |
| 168 bool SSLPostConnectionCheck(SSL* ssl, const char* server_name, | 170 bool SSLPostConnectionCheck(SSL* ssl, |
| 169 const X509* peer_cert, | 171 const char* server_name, |
| 170 const std::string& peer_digest); | 172 const X509* peer_cert); |
| 173 bool VerifyPeerCertificate(); |
| 171 // SSL certification verification error handler, called back from | 174 // SSL certification verification error handler, called back from |
| 172 // the openssl library. Returns an int interpreted as a boolean in | 175 // the openssl library. Returns an int interpreted as a boolean in |
| 173 // the C style: zero means verification failure, non-zero means | 176 // the C style: zero means verification failure, non-zero means |
| 174 // passed. | 177 // passed. |
| 175 static int SSLVerifyCallback(int ok, X509_STORE_CTX* store); | 178 static int SSLVerifyCallback(int ok, X509_STORE_CTX* store); |
| 176 | 179 |
| 177 SSLState state_; | 180 SSLState state_; |
| 178 SSLRole role_; | 181 SSLRole role_; |
| 179 int ssl_error_code_; // valid when state_ == SSL_ERROR or SSL_CLOSED | 182 int ssl_error_code_; // valid when state_ == SSL_ERROR or SSL_CLOSED |
| 180 // Whether the SSL negotiation is blocked on needing to read or | 183 // Whether the SSL negotiation is blocked on needing to read or |
| 181 // write to the wrapped stream. | 184 // write to the wrapped stream. |
| 182 bool ssl_read_needs_write_; | 185 bool ssl_read_needs_write_; |
| 183 bool ssl_write_needs_read_; | 186 bool ssl_write_needs_read_; |
| 184 | 187 |
| 185 SSL* ssl_; | 188 SSL* ssl_; |
| 186 SSL_CTX* ssl_ctx_; | 189 SSL_CTX* ssl_ctx_; |
| 187 | 190 |
| 188 // Our key and certificate, mostly useful in peer-to-peer mode. | 191 // Our key and certificate, mostly useful in peer-to-peer mode. |
| 189 std::unique_ptr<OpenSSLIdentity> identity_; | 192 std::unique_ptr<OpenSSLIdentity> identity_; |
| 190 // in traditional mode, the server name that the server's certificate | 193 // in traditional mode, the server name that the server's certificate |
| 191 // must specify. Empty in peer-to-peer mode. | 194 // must specify. Empty in peer-to-peer mode. |
| 192 std::string ssl_server_name_; | 195 std::string ssl_server_name_; |
| 193 // The certificate that the peer must present or did present. Initially | 196 // The certificate that the peer must present or did present. Initially |
| 194 // null in traditional mode, until the connection is established. | 197 // null in traditional mode, until the connection is established. |
| 195 std::unique_ptr<OpenSSLCertificate> peer_certificate_; | 198 std::unique_ptr<OpenSSLCertificate> peer_certificate_; |
| 196 // In peer-to-peer mode, the digest of the certificate that | 199 // In peer-to-peer mode, the digest of the certificate that |
| 197 // the peer must present. | 200 // the peer must present. |
| 198 Buffer peer_certificate_digest_value_; | 201 Buffer peer_certificate_digest_value_; |
| 199 std::string peer_certificate_digest_algorithm_; | 202 std::string peer_certificate_digest_algorithm_; |
| 203 bool certificate_verified_ = false; |
| 200 | 204 |
| 201 // OpenSSLAdapter::custom_verify_callback_ result | 205 // OpenSSLAdapter::custom_verify_callback_ result |
| 202 bool custom_verification_succeeded_; | 206 bool custom_verification_succeeded_; |
| 203 | 207 |
| 204 // The DtlsSrtp ciphers | 208 // The DtlsSrtp ciphers |
| 205 std::string srtp_ciphers_; | 209 std::string srtp_ciphers_; |
| 206 | 210 |
| 207 // Do DTLS or not | 211 // Do DTLS or not |
| 208 SSLMode ssl_mode_; | 212 SSLMode ssl_mode_; |
| 209 | 213 |
| 210 // Max. allowed protocol version | 214 // Max. allowed protocol version |
| 211 SSLProtocolVersion ssl_max_version_; | 215 SSLProtocolVersion ssl_max_version_; |
| 212 }; | 216 }; |
| 213 | 217 |
| 214 ///////////////////////////////////////////////////////////////////////////// | 218 ///////////////////////////////////////////////////////////////////////////// |
| 215 | 219 |
| 216 } // namespace rtc | 220 } // namespace rtc |
| 217 | 221 |
| 218 #endif // WEBRTC_BASE_OPENSSLSTREAMADAPTER_H__ | 222 #endif // WEBRTC_BASE_OPENSSLSTREAMADAPTER_H__ |
| OLD | NEW |