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

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

Issue 1545034: Do not call NSS functions if NSS initialization failed.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 10 years, 8 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 | « net/base/x509_certificate_nss.cc ('k') | 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) 2006-2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2009 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 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 EnterFunction(""); 252 EnterFunction("");
253 Disconnect(); 253 Disconnect();
254 LeaveFunction(""); 254 LeaveFunction("");
255 } 255 }
256 256
257 int SSLClientSocketNSS::Init() { 257 int SSLClientSocketNSS::Init() {
258 EnterFunction(""); 258 EnterFunction("");
259 // Initialize the NSS SSL library in a threadsafe way. This also 259 // Initialize the NSS SSL library in a threadsafe way. This also
260 // initializes the NSS base library. 260 // initializes the NSS base library.
261 EnsureNSSSSLInit(); 261 EnsureNSSSSLInit();
262 if (!NSS_IsInitialized())
263 return ERR_UNEXPECTED;
262 #if !defined(OS_WIN) 264 #if !defined(OS_WIN)
263 // We must call EnsureOCSPInit() here, on the IO thread, to get the IO loop 265 // We must call EnsureOCSPInit() here, on the IO thread, to get the IO loop
264 // by MessageLoopForIO::current(). 266 // by MessageLoopForIO::current().
265 // X509Certificate::Verify() runs on a worker thread of CertVerifier. 267 // X509Certificate::Verify() runs on a worker thread of CertVerifier.
266 EnsureOCSPInit(); 268 EnsureOCSPInit();
267 #endif 269 #endif
268 270
269 LeaveFunction(""); 271 LeaveFunction("");
270 return OK; 272 return OK;
271 } 273 }
272 274
273 int SSLClientSocketNSS::Connect(CompletionCallback* callback, 275 int SSLClientSocketNSS::Connect(CompletionCallback* callback,
274 const BoundNetLog& net_log) { 276 const BoundNetLog& net_log) {
275 EnterFunction(""); 277 EnterFunction("");
276 DCHECK(transport_.get()); 278 DCHECK(transport_.get());
277 DCHECK(next_handshake_state_ == STATE_NONE); 279 DCHECK(next_handshake_state_ == STATE_NONE);
278 DCHECK(!user_read_callback_); 280 DCHECK(!user_read_callback_);
279 DCHECK(!user_write_callback_); 281 DCHECK(!user_write_callback_);
280 DCHECK(!user_connect_callback_); 282 DCHECK(!user_connect_callback_);
281 DCHECK(!user_read_buf_); 283 DCHECK(!user_read_buf_);
282 DCHECK(!user_write_buf_); 284 DCHECK(!user_write_buf_);
283 285
284 net_log.BeginEvent(NetLog::TYPE_SSL_CONNECT); 286 net_log.BeginEvent(NetLog::TYPE_SSL_CONNECT);
285 287
286 if (Init() != OK) { 288 int rv = Init();
287 NOTREACHED() << "Couldn't initialize nss";
288 }
289
290 int rv = InitializeSSLOptions();
291 if (rv != OK) { 289 if (rv != OK) {
292 net_log.EndEvent(NetLog::TYPE_SSL_CONNECT); 290 net_log.EndEvent(NetLog::TYPE_SSL_CONNECT);
293 return rv; 291 return rv;
292 }
293
294 rv = InitializeSSLOptions();
295 if (rv != OK) {
296 net_log.EndEvent(NetLog::TYPE_SSL_CONNECT);
297 return rv;
294 } 298 }
295 299
296 GotoState(STATE_HANDSHAKE); 300 GotoState(STATE_HANDSHAKE);
297 rv = DoHandshakeLoop(OK); 301 rv = DoHandshakeLoop(OK);
298 if (rv == ERR_IO_PENDING) { 302 if (rv == ERR_IO_PENDING) {
299 user_connect_callback_ = callback; 303 user_connect_callback_ = callback;
300 net_log_ = net_log; 304 net_log_ = net_log;
301 } else { 305 } else {
302 net_log.EndEvent(NetLog::TYPE_SSL_CONNECT); 306 net_log.EndEvent(NetLog::TYPE_SSL_CONNECT);
303 } 307 }
(...skipping 1118 matching lines...) Expand 10 before | Expand all | Expand 10 after
1422 } 1426 }
1423 PRErrorCode prerr = PR_GetError(); 1427 PRErrorCode prerr = PR_GetError();
1424 if (prerr == PR_WOULD_BLOCK_ERROR) { 1428 if (prerr == PR_WOULD_BLOCK_ERROR) {
1425 return ERR_IO_PENDING; 1429 return ERR_IO_PENDING;
1426 } 1430 }
1427 LeaveFunction(""); 1431 LeaveFunction("");
1428 return MapNSPRError(prerr); 1432 return MapNSPRError(prerr);
1429 } 1433 }
1430 1434
1431 } // namespace net 1435 } // namespace net
OLDNEW
« no previous file with comments | « net/base/x509_certificate_nss.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698