Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(245)

Side by Side Diff: webrtc/base/openssladapter.h

Issue 2915243002: Fixing SSL error that occurs when underlying socket is blocked. (Closed)
Patch Set: Send an additional message while socket is blocked. Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | webrtc/base/openssladapter.cc » ('j') | webrtc/base/openssladapter.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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; |error| is
70 // an output parameter filled with the result of SSL_get_error.
71 int DoSslWrite(const void* pv, size_t cb, int* error);
72
68 void OnMessage(Message* msg) override; 73 void OnMessage(Message* msg) override;
69 74
70 static bool VerifyServerName(SSL* ssl, const char* host, 75 static bool VerifyServerName(SSL* ssl, const char* host,
71 bool ignore_bad_cert); 76 bool ignore_bad_cert);
72 bool SSLPostConnectionCheck(SSL* ssl, const char* host); 77 bool SSLPostConnectionCheck(SSL* ssl, const char* host);
73 #if !defined(NDEBUG) 78 #if !defined(NDEBUG)
74 static void SSLInfoCallback(const SSL* s, int where, int ret); 79 static void SSLInfoCallback(const SSL* s, int where, int ret);
75 #endif 80 #endif
76 static int SSLVerifyCallback(int ok, X509_STORE_CTX* store); 81 static int SSLVerifyCallback(int ok, X509_STORE_CTX* store);
77 static VerificationCallback custom_verify_callback_; 82 static VerificationCallback custom_verify_callback_;
78 friend class OpenSSLStreamAdapter; // for custom_verify_callback_; 83 friend class OpenSSLStreamAdapter; // for custom_verify_callback_;
79 84
80 static bool ConfigureTrustedRootCertificates(SSL_CTX* ctx); 85 static bool ConfigureTrustedRootCertificates(SSL_CTX* ctx);
81 SSL_CTX* SetupSSLContext(); 86 SSL_CTX* SetupSSLContext();
82 87
83 SSLState state_; 88 SSLState state_;
84 bool ssl_read_needs_write_; 89 bool ssl_read_needs_write_;
85 bool ssl_write_needs_read_; 90 bool ssl_write_needs_read_;
86 // If true, socket will retain SSL configuration after Close. 91 // If true, socket will retain SSL configuration after Close.
87 bool restartable_; 92 bool restartable_;
88 93
94 // This buffer is used if SSL_write fails with SSL_ERROR_WANT_WRITE, which
95 // means we need to keep retrying with *the same exact data* until it
96 // succeeds. Afterwards it will be cleared.
97 Buffer pending_data_;
98
89 SSL* ssl_; 99 SSL* ssl_;
90 SSL_CTX* ssl_ctx_; 100 SSL_CTX* ssl_ctx_;
91 std::string ssl_host_name_; 101 std::string ssl_host_name_;
92 // Do DTLS or not 102 // Do DTLS or not
93 SSLMode ssl_mode_; 103 SSLMode ssl_mode_;
94 104
95 bool custom_verification_succeeded_; 105 bool custom_verification_succeeded_;
96 }; 106 };
97 107
98 ///////////////////////////////////////////////////////////////////////////// 108 /////////////////////////////////////////////////////////////////////////////
99 109
100 } // namespace rtc 110 } // namespace rtc
101 111
102 #endif // WEBRTC_BASE_OPENSSLADAPTER_H__ 112 #endif // WEBRTC_BASE_OPENSSLADAPTER_H__
OLDNEW
« no previous file with comments | « no previous file | webrtc/base/openssladapter.cc » ('j') | webrtc/base/openssladapter.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698