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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 SSL_PROTOCOL_TLS_10, | 69 SSL_PROTOCOL_TLS_10, |
70 SSL_PROTOCOL_TLS_11, | 70 SSL_PROTOCOL_TLS_11, |
71 SSL_PROTOCOL_TLS_12, | 71 SSL_PROTOCOL_TLS_12, |
72 SSL_PROTOCOL_DTLS_10 = SSL_PROTOCOL_TLS_11, | 72 SSL_PROTOCOL_DTLS_10 = SSL_PROTOCOL_TLS_11, |
73 SSL_PROTOCOL_DTLS_12 = SSL_PROTOCOL_TLS_12, | 73 SSL_PROTOCOL_DTLS_12 = SSL_PROTOCOL_TLS_12, |
74 }; | 74 }; |
75 | 75 |
76 // Errors for Read -- in the high range so no conflict with OpenSSL. | 76 // Errors for Read -- in the high range so no conflict with OpenSSL. |
77 enum { SSE_MSG_TRUNC = 0xff0001 }; | 77 enum { SSE_MSG_TRUNC = 0xff0001 }; |
78 | 78 |
| 79 // Used to send back UMA histogram value. |
| 80 enum class SSLHandshakeError { UNKNOWN, INCOMPATIBLE_CIPHERSUITE, MAX_VALUE }; |
| 81 |
79 class SSLStreamAdapter : public StreamAdapterInterface { | 82 class SSLStreamAdapter : public StreamAdapterInterface { |
80 public: | 83 public: |
81 // Instantiate an SSLStreamAdapter wrapping the given stream, | 84 // Instantiate an SSLStreamAdapter wrapping the given stream, |
82 // (using the selected implementation for the platform). | 85 // (using the selected implementation for the platform). |
83 // Caller is responsible for freeing the returned object. | 86 // Caller is responsible for freeing the returned object. |
84 static SSLStreamAdapter* Create(StreamInterface* stream); | 87 static SSLStreamAdapter* Create(StreamInterface* stream); |
85 | 88 |
86 explicit SSLStreamAdapter(StreamInterface* stream) | 89 explicit SSLStreamAdapter(StreamInterface* stream); |
87 : StreamAdapterInterface(stream), ignore_bad_cert_(false), | 90 ~SSLStreamAdapter() override; |
88 client_auth_enabled_(true) { } | |
89 | 91 |
90 void set_ignore_bad_cert(bool ignore) { ignore_bad_cert_ = ignore; } | 92 void set_ignore_bad_cert(bool ignore) { ignore_bad_cert_ = ignore; } |
91 bool ignore_bad_cert() const { return ignore_bad_cert_; } | 93 bool ignore_bad_cert() const { return ignore_bad_cert_; } |
92 | 94 |
93 void set_client_auth_enabled(bool enabled) { client_auth_enabled_ = enabled; } | 95 void set_client_auth_enabled(bool enabled) { client_auth_enabled_ = enabled; } |
94 bool client_auth_enabled() const { return client_auth_enabled_; } | 96 bool client_auth_enabled() const { return client_auth_enabled_; } |
95 | 97 |
96 // Specify our SSL identity: key and certificate. Mostly this is | 98 // Specify our SSL identity: key and certificate. Mostly this is |
97 // only used in the peer-to-peer mode (unless we actually want to | 99 // only used in the peer-to-peer mode (unless we actually want to |
98 // provide a client certificate to a server). | 100 // provide a client certificate to a server). |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 // Returns true iff the supplied cipher is deemed to be strong. | 202 // Returns true iff the supplied cipher is deemed to be strong. |
201 // TODO(torbjorng): Consider removing the KeyType argument. | 203 // TODO(torbjorng): Consider removing the KeyType argument. |
202 static bool IsAcceptableCipher(int cipher, KeyType key_type); | 204 static bool IsAcceptableCipher(int cipher, KeyType key_type); |
203 static bool IsAcceptableCipher(const std::string& cipher, KeyType key_type); | 205 static bool IsAcceptableCipher(const std::string& cipher, KeyType key_type); |
204 | 206 |
205 // TODO(guoweis): Move this away from a static class method. Currently this is | 207 // TODO(guoweis): Move this away from a static class method. Currently this is |
206 // introduced such that any caller could depend on sslstreamadapter.h without | 208 // introduced such that any caller could depend on sslstreamadapter.h without |
207 // depending on specific SSL implementation. | 209 // depending on specific SSL implementation. |
208 static std::string SslCipherSuiteToName(int cipher_suite); | 210 static std::string SslCipherSuiteToName(int cipher_suite); |
209 | 211 |
| 212 sigslot::signal1<SSLHandshakeError> SignalSSLHandshakeError; |
| 213 |
210 private: | 214 private: |
211 // If true, the server certificate need not match the configured | 215 // If true, the server certificate need not match the configured |
212 // server_name, and in fact missing certificate authority and other | 216 // server_name, and in fact missing certificate authority and other |
213 // verification errors are ignored. | 217 // verification errors are ignored. |
214 bool ignore_bad_cert_; | 218 bool ignore_bad_cert_; |
215 | 219 |
216 // If true (default), the client is required to provide a certificate during | 220 // If true (default), the client is required to provide a certificate during |
217 // handshake. If no certificate is given, handshake fails. This applies to | 221 // handshake. If no certificate is given, handshake fails. This applies to |
218 // server mode only. | 222 // server mode only. |
219 bool client_auth_enabled_; | 223 bool client_auth_enabled_; |
220 }; | 224 }; |
221 | 225 |
222 } // namespace rtc | 226 } // namespace rtc |
223 | 227 |
224 #endif // WEBRTC_BASE_SSLSTREAMADAPTER_H_ | 228 #endif // WEBRTC_BASE_SSLSTREAMADAPTER_H_ |
OLD | NEW |