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

Side by Side Diff: net/base/x509_certificate_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 | « base/nss_util.cc ('k') | net/socket/ssl_client_socket_nss.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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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/base/x509_certificate.h" 5 #include "net/base/x509_certificate.h"
6 6
7 #include <cert.h> 7 #include <cert.h>
8 #include <nss.h>
8 #include <pk11pub.h> 9 #include <pk11pub.h>
9 #include <prerror.h> 10 #include <prerror.h>
10 #include <prtime.h> 11 #include <prtime.h>
11 #include <secder.h> 12 #include <secder.h>
12 #include <secerr.h> 13 #include <secerr.h>
13 #include <sechash.h> 14 #include <sechash.h>
14 #include <sslerr.h> 15 #include <sslerr.h>
15 16
16 #include "base/logging.h" 17 #include "base/logging.h"
17 #include "base/pickle.h" 18 #include "base/pickle.h"
(...skipping 697 matching lines...) Expand 10 before | Expand all | Expand 10 after
715 return false; 716 return false;
716 717
717 return true; 718 return true;
718 } 719 }
719 720
720 // static 721 // static
721 X509Certificate::OSCertHandle X509Certificate::CreateOSCertHandleFromBytes( 722 X509Certificate::OSCertHandle X509Certificate::CreateOSCertHandleFromBytes(
722 const char* data, int length) { 723 const char* data, int length) {
723 base::EnsureNSSInit(); 724 base::EnsureNSSInit();
724 725
726 if (!NSS_IsInitialized())
727 return NULL;
728
725 // Make a copy of |data| since CERT_DecodeCertPackage might modify it. 729 // Make a copy of |data| since CERT_DecodeCertPackage might modify it.
726 char* data_copy = new char[length]; 730 char* data_copy = new char[length];
727 memcpy(data_copy, data, length); 731 memcpy(data_copy, data, length);
728 732
729 // Parse into a certificate structure. 733 // Parse into a certificate structure.
730 CERTCertificate* cert = CERT_DecodeCertFromPackage(data_copy, length); 734 CERTCertificate* cert = CERT_DecodeCertFromPackage(data_copy, length);
731 delete [] data_copy; 735 delete [] data_copy;
732 if (!cert) 736 if (!cert)
733 LOG(ERROR) << "Couldn't parse a certificate from " << length << " bytes"; 737 LOG(ERROR) << "Couldn't parse a certificate from " << length << " bytes";
734 return cert; 738 return cert;
(...skipping 20 matching lines...) Expand all
755 DCHECK(0 != cert->derCert.len); 759 DCHECK(0 != cert->derCert.len);
756 760
757 SECStatus rv = HASH_HashBuf(HASH_AlgSHA1, sha1.data, 761 SECStatus rv = HASH_HashBuf(HASH_AlgSHA1, sha1.data,
758 cert->derCert.data, cert->derCert.len); 762 cert->derCert.data, cert->derCert.len);
759 DCHECK(rv == SECSuccess); 763 DCHECK(rv == SECSuccess);
760 764
761 return sha1; 765 return sha1;
762 } 766 }
763 767
764 } // namespace net 768 } // namespace net
OLDNEW
« no previous file with comments | « base/nss_util.cc ('k') | net/socket/ssl_client_socket_nss.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698