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

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

Issue 2867026: Make X509Certificate::CreateFromHandle() copy the OSCertHandle, rather than assume ownership (Closed)
Patch Set: Deleted one comment too many Created 10 years, 5 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 | « net/socket/ssl_client_socket_mac.cc ('k') | net/socket/ssl_client_socket_win.cc » ('j') | 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 // 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 705 matching lines...) Expand 10 before | Expand all | Expand 10 after
716 CERT_DestroyCertList(cert_list); 716 CERT_DestroyCertList(cert_list);
717 } 717 }
718 718
719 // Finally create the X509Certificate object. 719 // Finally create the X509Certificate object.
720 cert_handle = CreateOSCert(server_cert_nss_->derCert); 720 cert_handle = CreateOSCert(server_cert_nss_->derCert);
721 DCHECK(cert_handle); 721 DCHECK(cert_handle);
722 server_cert_ = X509Certificate::CreateFromHandle( 722 server_cert_ = X509Certificate::CreateFromHandle(
723 cert_handle, 723 cert_handle,
724 X509Certificate::SOURCE_FROM_NETWORK, 724 X509Certificate::SOURCE_FROM_NETWORK,
725 intermediate_ca_certs); 725 intermediate_ca_certs);
726 X509Certificate::FreeOSCertHandle(cert_handle);
726 for (size_t i = 0; i < intermediate_ca_certs.size(); ++i) 727 for (size_t i = 0; i < intermediate_ca_certs.size(); ++i)
727 X509Certificate::FreeOSCertHandle(intermediate_ca_certs[i]); 728 X509Certificate::FreeOSCertHandle(intermediate_ca_certs[i]);
728 #else 729 #else
729 server_cert_ = X509Certificate::CreateFromHandle( 730 server_cert_ = X509Certificate::CreateFromHandle(
730 CERT_DupCertificate(server_cert_nss_), 731 server_cert_nss_,
731 X509Certificate::SOURCE_FROM_NETWORK, 732 X509Certificate::SOURCE_FROM_NETWORK,
732 X509Certificate::OSCertHandles()); 733 X509Certificate::OSCertHandles());
733 #endif 734 #endif
734 } 735 }
735 } 736 }
736 return server_cert_; 737 return server_cert_;
737 } 738 }
738 739
739 // Log an informational message if the server does not support secure 740 // Log an informational message if the server does not support secure
740 // renegotiation (RFC 5746). 741 // renegotiation (RFC 5746).
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after
1250 PCCERT_CONTEXT cert_context2; 1251 PCCERT_CONTEXT cert_context2;
1251 BOOL ok = CertAddCertificateContextToStore(cert_store_, cert_context, 1252 BOOL ok = CertAddCertificateContextToStore(cert_store_, cert_context,
1252 CERT_STORE_ADD_USE_EXISTING, 1253 CERT_STORE_ADD_USE_EXISTING,
1253 &cert_context2); 1254 &cert_context2);
1254 if (!ok) { 1255 if (!ok) {
1255 NOTREACHED(); 1256 NOTREACHED();
1256 continue; 1257 continue;
1257 } 1258 }
1258 scoped_refptr<X509Certificate> cert = X509Certificate::CreateFromHandle( 1259 scoped_refptr<X509Certificate> cert = X509Certificate::CreateFromHandle(
1259 cert_context2, X509Certificate::SOURCE_LONE_CERT_IMPORT, 1260 cert_context2, X509Certificate::SOURCE_LONE_CERT_IMPORT,
1260 net::X509Certificate::OSCertHandles()); 1261 X509Certificate::OSCertHandles());
1262 X509Certificate::FreeOSCertHandle(cert_context2);
1261 that->client_certs_.push_back(cert); 1263 that->client_certs_.push_back(cert);
1262 } 1264 }
1263 1265
1264 BOOL ok = CertCloseStore(my_cert_store, CERT_CLOSE_STORE_CHECK_FLAG); 1266 BOOL ok = CertCloseStore(my_cert_store, CERT_CLOSE_STORE_CHECK_FLAG);
1265 DCHECK(ok); 1267 DCHECK(ok);
1266 1268
1267 // Tell NSS to suspend the client authentication. We will then abort the 1269 // Tell NSS to suspend the client authentication. We will then abort the
1268 // handshake by returning ERR_SSL_CLIENT_AUTH_CERT_NEEDED. 1270 // handshake by returning ERR_SSL_CLIENT_AUTH_CERT_NEEDED.
1269 return SECWouldBlock; 1271 return SECWouldBlock;
1270 #elif defined(OS_MACOSX) 1272 #elif defined(OS_MACOSX)
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
1335 // Only check unexpired certs. 1337 // Only check unexpired certs.
1336 if (CERT_CheckCertValidTimes(cert, PR_Now(), PR_TRUE) == 1338 if (CERT_CheckCertValidTimes(cert, PR_Now(), PR_TRUE) ==
1337 secCertTimeValid && (!ca_names->nnames || 1339 secCertTimeValid && (!ca_names->nnames ||
1338 NSS_CmpCertChainWCANames(cert, ca_names) == SECSuccess)) { 1340 NSS_CmpCertChainWCANames(cert, ca_names) == SECSuccess)) {
1339 privkey = PK11_FindKeyByAnyCert(cert, wincx); 1341 privkey = PK11_FindKeyByAnyCert(cert, wincx);
1340 if (privkey) { 1342 if (privkey) {
1341 X509Certificate* x509_cert = X509Certificate::CreateFromHandle( 1343 X509Certificate* x509_cert = X509Certificate::CreateFromHandle(
1342 cert, X509Certificate::SOURCE_LONE_CERT_IMPORT, 1344 cert, X509Certificate::SOURCE_LONE_CERT_IMPORT,
1343 net::X509Certificate::OSCertHandles()); 1345 net::X509Certificate::OSCertHandles());
1344 that->client_certs_.push_back(x509_cert); 1346 that->client_certs_.push_back(x509_cert);
1347 CERT_DestroyCertificate(cert);
1345 SECKEY_DestroyPrivateKey(privkey); 1348 SECKEY_DestroyPrivateKey(privkey);
1346 continue; 1349 continue;
1347 } 1350 }
1348 } 1351 }
1349 CERT_DestroyCertificate(cert); 1352 CERT_DestroyCertificate(cert);
1350 } 1353 }
1351 CERT_FreeNicknames(names); 1354 CERT_FreeNicknames(names);
1352 } 1355 }
1353 1356
1354 // Tell NSS to suspend the client authentication. We will then abort the 1357 // Tell NSS to suspend the client authentication. We will then abort the
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
1542 PRErrorCode prerr = PR_GetError(); 1545 PRErrorCode prerr = PR_GetError();
1543 if (prerr == PR_WOULD_BLOCK_ERROR) { 1546 if (prerr == PR_WOULD_BLOCK_ERROR) {
1544 LeaveFunction(""); 1547 LeaveFunction("");
1545 return ERR_IO_PENDING; 1548 return ERR_IO_PENDING;
1546 } 1549 }
1547 LeaveFunction(""); 1550 LeaveFunction("");
1548 return MapNSPRError(prerr); 1551 return MapNSPRError(prerr);
1549 } 1552 }
1550 1553
1551 } // namespace net 1554 } // namespace net
OLDNEW
« no previous file with comments | « net/socket/ssl_client_socket_mac.cc ('k') | net/socket/ssl_client_socket_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698