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

Side by Side Diff: net/socket/ssl_client_socket_mac.cc

Issue 6250001: Merge 70858 - Disable SSL renegotiation on OS X when using system SSL and on ... (Closed) Base URL: svn://svn.chromium.org/chrome/branches/597/src/
Patch Set: Created 9 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/socket/ssl_client_socket_mac.h" 5 #include "net/socket/ssl_client_socket_mac.h"
6 6
7 #include <CoreServices/CoreServices.h> 7 #include <CoreServices/CoreServices.h>
8 #include <netdb.h> 8 #include <netdb.h>
9 #include <sys/socket.h> 9 #include <sys/socket.h>
10 #include <sys/types.h> 10 #include <sys/types.h>
11 11
12 #include <algorithm> 12 #include <algorithm>
13 13
14 #include "base/lazy_instance.h"
14 #include "base/mac/scoped_cftyperef.h" 15 #include "base/mac/scoped_cftyperef.h"
15 #include "base/singleton.h" 16 #include "base/singleton.h"
16 #include "base/string_util.h" 17 #include "base/string_util.h"
18 #include "base/sys_info.h"
17 #include "net/base/address_list.h" 19 #include "net/base/address_list.h"
18 #include "net/base/cert_verifier.h" 20 #include "net/base/cert_verifier.h"
19 #include "net/base/io_buffer.h" 21 #include "net/base/io_buffer.h"
20 #include "net/base/net_errors.h" 22 #include "net/base/net_errors.h"
21 #include "net/base/net_log.h" 23 #include "net/base/net_log.h"
22 #include "net/base/ssl_cert_request_info.h" 24 #include "net/base/ssl_cert_request_info.h"
23 #include "net/base/ssl_connection_status_flags.h" 25 #include "net/base/ssl_connection_status_flags.h"
24 #include "net/base/ssl_info.h" 26 #include "net/base/ssl_info.h"
25 #include "net/socket/client_socket_handle.h" 27 #include "net/socket/client_socket_handle.h"
26 #include "net/socket/ssl_error_params.h" 28 #include "net/socket/ssl_error_params.h"
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA = 0xC013, 135 TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA = 0xC013,
134 TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA = 0xC014, 136 TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA = 0xC014,
135 TLS_ECDH_anon_WITH_NULL_SHA = 0xC015, 137 TLS_ECDH_anon_WITH_NULL_SHA = 0xC015,
136 TLS_ECDH_anon_WITH_RC4_128_SHA = 0xC016, 138 TLS_ECDH_anon_WITH_RC4_128_SHA = 0xC016,
137 TLS_ECDH_anon_WITH_3DES_EDE_CBC_SHA = 0xC017, 139 TLS_ECDH_anon_WITH_3DES_EDE_CBC_SHA = 0xC017,
138 TLS_ECDH_anon_WITH_AES_128_CBC_SHA = 0xC018, 140 TLS_ECDH_anon_WITH_AES_128_CBC_SHA = 0xC018,
139 TLS_ECDH_anon_WITH_AES_256_CBC_SHA = 0xC019, 141 TLS_ECDH_anon_WITH_AES_256_CBC_SHA = 0xC019,
140 }; 142 };
141 #endif 143 #endif
142 144
145 // On OS X 10.5.x, SSLHandshake() is broken with respect to renegotiation
146 // handshakes, and the only way to advance the handshake state machine is
147 // to use SSLRead(), which transparently re-handshakes and then reads
148 // application data. Using SSLRead() to pump the handshake, rather than
149 // SSLHandshake(), is not presently implemented, so on 10.5.x, SSL
150 // renegotiation is disabled entirely. On 10.6.x, SSLHandshake() behaves as
151 // expected/documented, so renegotiation is supported.
152 struct RenegotiationBroken {
153 RenegotiationBroken() : broken(false) {
154 int32 major, minor, bugfix;
155 base::SysInfo::OperatingSystemVersionNumbers(&major, &minor, &bugfix);
156 if (major < 10 || (major == 10 && minor < 6))
157 broken = true;
158 }
159
160 bool broken;
161 };
162
163 base::LazyInstance<RenegotiationBroken> g_renegotiation_broken(
164 base::LINKER_INITIALIZED);
165
143 // For an explanation of the Mac OS X error codes, please refer to: 166 // For an explanation of the Mac OS X error codes, please refer to:
144 // http://developer.apple.com/mac/library/documentation/Security/Reference/secur eTransportRef/Reference/reference.html 167 // http://developer.apple.com/mac/library/documentation/Security/Reference/secur eTransportRef/Reference/reference.html
145 int NetErrorFromOSStatus(OSStatus status) { 168 int NetErrorFromOSStatus(OSStatus status) {
146 switch (status) { 169 switch (status) {
147 case errSSLWouldBlock: 170 case errSSLWouldBlock:
148 return ERR_IO_PENDING; 171 return ERR_IO_PENDING;
149 case paramErr: 172 case paramErr:
150 case errSSLBadCipherSuite: 173 case errSSLBadCipherSuite:
151 case errSSLBadConfiguration: 174 case errSSLBadConfiguration:
152 return ERR_INVALID_ARGUMENT; 175 return ERR_INVALID_ARGUMENT;
(...skipping 954 matching lines...) Expand 10 before | Expand all | Expand 10 after
1107 if (result) 1130 if (result)
1108 LOG(ERROR) << "SSLSetCertificate returned OSStatus " << result; 1131 LOG(ERROR) << "SSLSetCertificate returned OSStatus " << result;
1109 return result; 1132 return result;
1110 } 1133 }
1111 1134
1112 int SSLClientSocketMac::DoPayloadRead() { 1135 int SSLClientSocketMac::DoPayloadRead() {
1113 size_t processed = 0; 1136 size_t processed = 0;
1114 OSStatus status = SSLRead(ssl_context_, user_read_buf_->data(), 1137 OSStatus status = SSLRead(ssl_context_, user_read_buf_->data(),
1115 user_read_buf_len_, &processed); 1138 user_read_buf_len_, &processed);
1116 if (status == errSSLWouldBlock && renegotiating_) { 1139 if (status == errSSLWouldBlock && renegotiating_) {
1140 if (g_renegotiation_broken.Get().broken)
1141 return ERR_SSL_RENEGOTIATION_REQUESTED;
1142
1117 CHECK_EQ(static_cast<size_t>(0), processed); 1143 CHECK_EQ(static_cast<size_t>(0), processed);
1118 next_handshake_state_ = STATE_HANDSHAKE; 1144 next_handshake_state_ = STATE_HANDSHAKE;
1119 return DoHandshakeLoop(OK); 1145 return DoHandshakeLoop(OK);
1120 } 1146 }
1121 // There's a subtle difference here in semantics of the "would block" errors. 1147 // There's a subtle difference here in semantics of the "would block" errors.
1122 // In our code, ERR_IO_PENDING means the whole operation is async, while 1148 // In our code, ERR_IO_PENDING means the whole operation is async, while
1123 // errSSLWouldBlock means that the stream isn't ending (and is often returned 1149 // errSSLWouldBlock means that the stream isn't ending (and is often returned
1124 // along with partial data). So even though "would block" is returned, if we 1150 // along with partial data). So even though "would block" is returned, if we
1125 // have data, let's just return it. This is further complicated by the fact 1151 // have data, let's just return it. This is further complicated by the fact
1126 // that errSSLWouldBlock is also used to short-circuit SSLRead()'s 1152 // that errSSLWouldBlock is also used to short-circuit SSLRead()'s
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
1319 if (rv < 0 && rv != ERR_IO_PENDING) { 1345 if (rv < 0 && rv != ERR_IO_PENDING) {
1320 us->write_io_buf_ = NULL; 1346 us->write_io_buf_ = NULL;
1321 return OSStatusFromNetError(rv); 1347 return OSStatusFromNetError(rv);
1322 } 1348 }
1323 1349
1324 // always lie to our caller 1350 // always lie to our caller
1325 return noErr; 1351 return noErr;
1326 } 1352 }
1327 1353
1328 } // namespace net 1354 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698