| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // This file includes code SSLClientSocketNSS::DoVerifyCertComplete() derived | 5 // This file includes code SSLClientSocketNSS::DoVerifyCertComplete() derived |
| 6 // from AuthCertificateCallback() in | 6 // from AuthCertificateCallback() in |
| 7 // mozilla/security/manager/ssl/src/nsNSSCallbacks.cpp. | 7 // mozilla/security/manager/ssl/src/nsNSSCallbacks.cpp. |
| 8 | 8 |
| 9 /* ***** BEGIN LICENSE BLOCK ***** | 9 /* ***** BEGIN LICENSE BLOCK ***** |
| 10 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 | 10 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 |
| (...skipping 1240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1251 } | 1251 } |
| 1252 | 1252 |
| 1253 int rv = DoReadLoop(result); | 1253 int rv = DoReadLoop(result); |
| 1254 if (rv != ERR_IO_PENDING) | 1254 if (rv != ERR_IO_PENDING) |
| 1255 DoReadCallback(rv); | 1255 DoReadCallback(rv); |
| 1256 LeaveFunction(""); | 1256 LeaveFunction(""); |
| 1257 } | 1257 } |
| 1258 | 1258 |
| 1259 int SSLClientSocketNSS::DoHandshakeLoop(int last_io_result) { | 1259 int SSLClientSocketNSS::DoHandshakeLoop(int last_io_result) { |
| 1260 EnterFunction(last_io_result); | 1260 EnterFunction(last_io_result); |
| 1261 bool network_moved; | |
| 1262 int rv = last_io_result; | 1261 int rv = last_io_result; |
| 1263 do { | 1262 do { |
| 1264 // Default to STATE_NONE for next state. | 1263 // Default to STATE_NONE for next state. |
| 1265 // (This is a quirk carried over from the windows | 1264 // (This is a quirk carried over from the windows |
| 1266 // implementation. It makes reading the logs a bit harder.) | 1265 // implementation. It makes reading the logs a bit harder.) |
| 1267 // State handlers can and often do call GotoState just | 1266 // State handlers can and often do call GotoState just |
| 1268 // to stay in the current state. | 1267 // to stay in the current state. |
| 1269 State state = next_handshake_state_; | 1268 State state = next_handshake_state_; |
| 1270 GotoState(STATE_NONE); | 1269 GotoState(STATE_NONE); |
| 1271 switch (state) { | 1270 switch (state) { |
| 1272 case STATE_NONE: | |
| 1273 // we're just pumping data between the buffer and the network | |
| 1274 break; | |
| 1275 case STATE_LOAD_SSL_HOST_INFO: | 1271 case STATE_LOAD_SSL_HOST_INFO: |
| 1272 DCHECK(rv == OK || rv == ERR_IO_PENDING); |
| 1276 rv = DoLoadSSLHostInfo(); | 1273 rv = DoLoadSSLHostInfo(); |
| 1277 break; | 1274 break; |
| 1278 case STATE_HANDSHAKE: | 1275 case STATE_HANDSHAKE: |
| 1279 rv = DoHandshake(); | 1276 rv = DoHandshake(); |
| 1280 break; | 1277 break; |
| 1281 case STATE_GET_OB_CERT_COMPLETE: | 1278 case STATE_GET_OB_CERT_COMPLETE: |
| 1282 rv = DoGetOBCertComplete(rv); | 1279 rv = DoGetOBCertComplete(rv); |
| 1283 break; | 1280 break; |
| 1284 case STATE_VERIFY_DNSSEC: | 1281 case STATE_VERIFY_DNSSEC: |
| 1285 rv = DoVerifyDNSSEC(rv); | 1282 rv = DoVerifyDNSSEC(rv); |
| 1286 break; | 1283 break; |
| 1287 case STATE_VERIFY_CERT: | 1284 case STATE_VERIFY_CERT: |
| 1288 DCHECK(rv == OK); | 1285 DCHECK(rv == OK); |
| 1289 rv = DoVerifyCert(rv); | 1286 rv = DoVerifyCert(rv); |
| 1290 break; | 1287 break; |
| 1291 case STATE_VERIFY_CERT_COMPLETE: | 1288 case STATE_VERIFY_CERT_COMPLETE: |
| 1292 rv = DoVerifyCertComplete(rv); | 1289 rv = DoVerifyCertComplete(rv); |
| 1293 break; | 1290 break; |
| 1291 case STATE_NONE: |
| 1294 default: | 1292 default: |
| 1295 rv = ERR_UNEXPECTED; | 1293 rv = ERR_UNEXPECTED; |
| 1296 LOG(DFATAL) << "unexpected state " << state; | 1294 LOG(DFATAL) << "unexpected state " << state; |
| 1297 break; | 1295 break; |
| 1298 } | 1296 } |
| 1299 | 1297 |
| 1300 // Do the actual network I/O | 1298 // Do the actual network I/O |
| 1301 network_moved = DoTransportIO(); | 1299 bool network_moved = DoTransportIO(); |
| 1302 } while ((rv != ERR_IO_PENDING || network_moved) && | 1300 if (network_moved && next_handshake_state_ == STATE_HANDSHAKE) { |
| 1303 next_handshake_state_ != STATE_NONE); | 1301 // In general we exit the loop if rv is ERR_IO_PENDING. In this |
| 1302 // special case we keep looping even if rv is ERR_IO_PENDING because |
| 1303 // the transport IO may allow DoHandshake to make progress. |
| 1304 DCHECK(rv == OK || rv == ERR_IO_PENDING); |
| 1305 rv = OK; // This causes us to stay in the loop. |
| 1306 } |
| 1307 } while (rv != ERR_IO_PENDING && next_handshake_state_ != STATE_NONE); |
| 1304 LeaveFunction(""); | 1308 LeaveFunction(""); |
| 1305 return rv; | 1309 return rv; |
| 1306 } | 1310 } |
| 1307 | 1311 |
| 1308 int SSLClientSocketNSS::DoReadLoop(int result) { | 1312 int SSLClientSocketNSS::DoReadLoop(int result) { |
| 1309 EnterFunction(""); | 1313 EnterFunction(""); |
| 1310 DCHECK(completed_handshake_); | 1314 DCHECK(completed_handshake_); |
| 1311 DCHECK(next_handshake_state_ == STATE_NONE); | 1315 DCHECK(next_handshake_state_ == STATE_NONE); |
| 1312 | 1316 |
| 1313 if (result < 0) | 1317 if (result < 0) |
| (...skipping 1396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2710 valid_thread_id_ = base::PlatformThread::CurrentId(); | 2714 valid_thread_id_ = base::PlatformThread::CurrentId(); |
| 2711 } | 2715 } |
| 2712 | 2716 |
| 2713 bool SSLClientSocketNSS::CalledOnValidThread() const { | 2717 bool SSLClientSocketNSS::CalledOnValidThread() const { |
| 2714 EnsureThreadIdAssigned(); | 2718 EnsureThreadIdAssigned(); |
| 2715 base::AutoLock auto_lock(lock_); | 2719 base::AutoLock auto_lock(lock_); |
| 2716 return valid_thread_id_ == base::PlatformThread::CurrentId(); | 2720 return valid_thread_id_ == base::PlatformThread::CurrentId(); |
| 2717 } | 2721 } |
| 2718 | 2722 |
| 2719 } // namespace net | 2723 } // namespace net |
| OLD | NEW |