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 |
11 #ifndef WEBRTC_BASE_OPENSSLADAPTER_H__ | 11 #ifndef WEBRTC_BASE_OPENSSLADAPTER_H__ |
12 #define WEBRTC_BASE_OPENSSLADAPTER_H__ | 12 #define WEBRTC_BASE_OPENSSLADAPTER_H__ |
13 | 13 |
14 #include <string> | 14 #include <string> |
15 #include "webrtc/base/buffer.h" | |
15 #include "webrtc/base/messagehandler.h" | 16 #include "webrtc/base/messagehandler.h" |
16 #include "webrtc/base/messagequeue.h" | 17 #include "webrtc/base/messagequeue.h" |
17 #include "webrtc/base/ssladapter.h" | 18 #include "webrtc/base/ssladapter.h" |
18 | 19 |
19 typedef struct ssl_st SSL; | 20 typedef struct ssl_st SSL; |
20 typedef struct ssl_ctx_st SSL_CTX; | 21 typedef struct ssl_ctx_st SSL_CTX; |
21 typedef struct x509_store_ctx_st X509_STORE_CTX; | 22 typedef struct x509_store_ctx_st X509_STORE_CTX; |
22 | 23 |
23 namespace rtc { | 24 namespace rtc { |
24 | 25 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
58 SSL_NONE, SSL_WAIT, SSL_CONNECTING, SSL_CONNECTED, SSL_ERROR | 59 SSL_NONE, SSL_WAIT, SSL_CONNECTING, SSL_CONNECTED, SSL_ERROR |
59 }; | 60 }; |
60 | 61 |
61 enum { MSG_TIMEOUT }; | 62 enum { MSG_TIMEOUT }; |
62 | 63 |
63 int BeginSSL(); | 64 int BeginSSL(); |
64 int ContinueSSL(); | 65 int ContinueSSL(); |
65 void Error(const char* context, int err, bool signal = true); | 66 void Error(const char* context, int err, bool signal = true); |
66 void Cleanup(); | 67 void Cleanup(); |
67 | 68 |
69 // Return value and arguments have the same meanings as for Send. | |
70 int DoSslWrite(const void* pv, size_t cb); | |
71 | |
68 void OnMessage(Message* msg) override; | 72 void OnMessage(Message* msg) override; |
69 | 73 |
70 static bool VerifyServerName(SSL* ssl, const char* host, | 74 static bool VerifyServerName(SSL* ssl, const char* host, |
71 bool ignore_bad_cert); | 75 bool ignore_bad_cert); |
72 bool SSLPostConnectionCheck(SSL* ssl, const char* host); | 76 bool SSLPostConnectionCheck(SSL* ssl, const char* host); |
73 #if !defined(NDEBUG) | 77 #if !defined(NDEBUG) |
74 static void SSLInfoCallback(const SSL* s, int where, int ret); | 78 static void SSLInfoCallback(const SSL* s, int where, int ret); |
75 #endif | 79 #endif |
76 static int SSLVerifyCallback(int ok, X509_STORE_CTX* store); | 80 static int SSLVerifyCallback(int ok, X509_STORE_CTX* store); |
77 static VerificationCallback custom_verify_callback_; | 81 static VerificationCallback custom_verify_callback_; |
78 friend class OpenSSLStreamAdapter; // for custom_verify_callback_; | 82 friend class OpenSSLStreamAdapter; // for custom_verify_callback_; |
79 | 83 |
80 static bool ConfigureTrustedRootCertificates(SSL_CTX* ctx); | 84 static bool ConfigureTrustedRootCertificates(SSL_CTX* ctx); |
81 SSL_CTX* SetupSSLContext(); | 85 SSL_CTX* SetupSSLContext(); |
82 | 86 |
83 SSLState state_; | 87 SSLState state_; |
84 bool ssl_read_needs_write_; | 88 bool ssl_read_needs_write_; |
85 bool ssl_write_needs_read_; | 89 bool ssl_write_needs_read_; |
86 // If true, socket will retain SSL configuration after Close. | 90 // If true, socket will retain SSL configuration after Close. |
87 bool restartable_; | 91 bool restartable_; |
88 | 92 |
93 // Set to true if SSL_write fails with SSL_ERROR_WANT_WRITE, which means we | |
94 // need to keep retrying with *the same exact data* until it succeeds. | |
95 bool pending_write_ = false; | |
96 Buffer pending_data_; | |
pthatcher1
2017/06/02 04:58:21
Why do we need both? Can't the non-emptiness of p
Taylor Brandstetter
2017/06/02 06:49:14
Sure, done.
| |
97 | |
89 SSL* ssl_; | 98 SSL* ssl_; |
90 SSL_CTX* ssl_ctx_; | 99 SSL_CTX* ssl_ctx_; |
91 std::string ssl_host_name_; | 100 std::string ssl_host_name_; |
92 // Do DTLS or not | 101 // Do DTLS or not |
93 SSLMode ssl_mode_; | 102 SSLMode ssl_mode_; |
94 | 103 |
95 bool custom_verification_succeeded_; | 104 bool custom_verification_succeeded_; |
96 }; | 105 }; |
97 | 106 |
98 ///////////////////////////////////////////////////////////////////////////// | 107 ///////////////////////////////////////////////////////////////////////////// |
99 | 108 |
100 } // namespace rtc | 109 } // namespace rtc |
101 | 110 |
102 #endif // WEBRTC_BASE_OPENSSLADAPTER_H__ | 111 #endif // WEBRTC_BASE_OPENSSLADAPTER_H__ |
OLD | NEW |