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

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

Issue 7995009: net: fix crash when failing to import a client-side cert into NSS. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ... Created 9 years, 3 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_server_socket_nss.h" 5 #include "net/socket/ssl_server_socket_nss.h"
6 6
7 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <winsock2.h> 8 #include <winsock2.h>
9 #endif 9 #endif
10 10
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 362
363 SECItem der_cert; 363 SECItem der_cert;
364 der_cert.data = reinterpret_cast<unsigned char*>(const_cast<char*>( 364 der_cert.data = reinterpret_cast<unsigned char*>(const_cast<char*>(
365 der_string.data())); 365 der_string.data()));
366 der_cert.len = der_string.length(); 366 der_cert.len = der_string.length();
367 der_cert.type = siDERCertBuffer; 367 der_cert.type = siDERCertBuffer;
368 368
369 // Parse into a CERTCertificate structure. 369 // Parse into a CERTCertificate structure.
370 CERTCertificate* cert = CERT_NewTempCertificate( 370 CERTCertificate* cert = CERT_NewTempCertificate(
371 CERT_GetDefaultCertDB(), &der_cert, NULL, PR_FALSE, PR_TRUE); 371 CERT_GetDefaultCertDB(), &der_cert, NULL, PR_FALSE, PR_TRUE);
372 if (!cert) {
373 LogFailedNSSFunction(net_log_, "CERT_NewTempCertificate", "");
374 return ERR_UNEXPECTED;
wtc 2011/09/23 00:55:55 Let's return MapNSSError(PORT_GetError()) instead.
agl 2011/09/23 17:52:22 Done.
375 }
372 376
373 // Get a key of SECKEYPrivateKey* structure. 377 // Get a key of SECKEYPrivateKey* structure.
374 std::vector<uint8> key_vector; 378 std::vector<uint8> key_vector;
375 if (!key_->ExportPrivateKey(&key_vector)) { 379 if (!key_->ExportPrivateKey(&key_vector)) {
376 CERT_DestroyCertificate(cert); 380 CERT_DestroyCertificate(cert);
377 return ERR_UNEXPECTED; 381 return ERR_UNEXPECTED;
378 } 382 }
379 383
380 SECKEYPrivateKeyStr* private_key = NULL; 384 SECKEYPrivateKeyStr* private_key = NULL;
381 PK11SlotInfo* slot = crypto::GetPrivateNSSKeySlot(); 385 PK11SlotInfo* slot = crypto::GetPrivateNSSKeySlot();
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
760 // Initialize the NSS SSL library in a threadsafe way. This also 764 // Initialize the NSS SSL library in a threadsafe way. This also
761 // initializes the NSS base library. 765 // initializes the NSS base library.
762 EnsureNSSSSLInit(); 766 EnsureNSSSSLInit();
763 if (!NSS_IsInitialized()) 767 if (!NSS_IsInitialized())
764 return ERR_UNEXPECTED; 768 return ERR_UNEXPECTED;
765 769
766 return OK; 770 return OK;
767 } 771 }
768 772
769 } // namespace net 773 } // namespace net
OLDNEW
« net/socket/ssl_client_socket_nss.cc ('K') | « net/socket/ssl_client_socket_nss.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698