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

Side by Side Diff: net/base/x509_certificate_nss.cc

Issue 6793026: Initial support for HSTS certificate locking. This isn't a finished work, but (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 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
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/base/x509_certificate.h" 5 #include "net/base/x509_certificate.h"
6 6
7 #include <cert.h> 7 #include <cert.h>
8 #include <cryptohi.h> 8 #include <cryptohi.h>
9 #include <keyhi.h> 9 #include <keyhi.h>
10 #include <nss.h> 10 #include <nss.h>
(...skipping 931 matching lines...) Expand 10 before | Expand all | Expand 10 after
942 OSCertHandle cert_handle) { 942 OSCertHandle cert_handle) {
943 return CERT_DupCertificate(cert_handle); 943 return CERT_DupCertificate(cert_handle);
944 } 944 }
945 945
946 // static 946 // static
947 void X509Certificate::FreeOSCertHandle(OSCertHandle cert_handle) { 947 void X509Certificate::FreeOSCertHandle(OSCertHandle cert_handle) {
948 CERT_DestroyCertificate(cert_handle); 948 CERT_DestroyCertificate(cert_handle);
949 } 949 }
950 950
951 // static 951 // static
952 void X509Certificate::GetCertChainFromCert(OSCertHandle cert_handle,
953 OSCertHandles* cert_handles) {
954 CERTCertList* cert_list =
955 CERT_GetCertChainFromCert(cert_handle, PR_Now(), certUsageSSLServer);
wtc 2011/04/07 01:00:29 The certificate chain is readily available in the
956 CERTCertListNode* node;
957 for (node = CERT_LIST_HEAD(cert_list);
958 !CERT_LIST_END(node, cert_list);
959 node = CERT_LIST_NEXT(node)) {
960 cert_handles->push_back(CERT_DupCertificate(node->cert));
961 }
962 CERT_DestroyCertList(cert_list);
963 }
964
965 // static
966 void X509Certificate::DestroyCertChain(OSCertHandles* cert_handles) {
967 for (OSCertHandles::iterator i(cert_handles->begin());
968 i != cert_handles->end(); ++i)
969 CERT_DestroyCertificate(*i);
970 cert_handles->clear();
971 }
972
973 // static
952 SHA1Fingerprint X509Certificate::CalculateFingerprint( 974 SHA1Fingerprint X509Certificate::CalculateFingerprint(
953 OSCertHandle cert) { 975 OSCertHandle cert) {
954 SHA1Fingerprint sha1; 976 SHA1Fingerprint sha1;
955 memset(sha1.data, 0, sizeof(sha1.data)); 977 memset(sha1.data, 0, sizeof(sha1.data));
956 978
957 DCHECK(NULL != cert->derCert.data); 979 DCHECK(NULL != cert->derCert.data);
958 DCHECK(0 != cert->derCert.len); 980 DCHECK(0 != cert->derCert.len);
959 981
960 SECStatus rv = HASH_HashBuf(HASH_AlgSHA1, sha1.data, 982 SECStatus rv = HASH_HashBuf(HASH_AlgSHA1, sha1.data,
961 cert->derCert.data, cert->derCert.len); 983 cert->derCert.data, cert->derCert.len);
962 DCHECK(rv == SECSuccess); 984 DCHECK(rv == SECSuccess);
963 985
964 return sha1; 986 return sha1;
965 } 987 }
966 988
967 } // namespace net 989 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698