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

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

Issue 7473009: Revert r92977 partially to fix a certificate verification regression (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 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 | 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 <stdlib.h> 7 #include <stdlib.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <map> 10 #include <map>
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 } 241 }
242 242
243 // static 243 // static
244 X509Certificate* X509Certificate::CreateFromHandle( 244 X509Certificate* X509Certificate::CreateFromHandle(
245 OSCertHandle cert_handle, 245 OSCertHandle cert_handle,
246 const OSCertHandles& intermediates) { 246 const OSCertHandles& intermediates) {
247 DCHECK(cert_handle); 247 DCHECK(cert_handle);
248 return new X509Certificate(cert_handle, intermediates); 248 return new X509Certificate(cert_handle, intermediates);
249 } 249 }
250 250
251 #if defined(OS_WIN)
252 static X509Certificate::OSCertHandle CreateOSCert(base::StringPiece der_cert) {
rvargas (doing something else) 2011/07/20 21:34:06 I know this is not really part of this change, but
253 X509Certificate::OSCertHandle cert_handle = NULL;
254 BOOL ok = CertAddEncodedCertificateToStore(
255 X509Certificate::cert_store(), X509_ASN_ENCODING | PKCS_7_ASN_ENCODING,
256 reinterpret_cast<const BYTE*>(der_cert.data()), der_cert.size(),
257 CERT_STORE_ADD_USE_EXISTING, &cert_handle);
258 return ok ? cert_handle : NULL;
259 }
260 #else
251 static X509Certificate::OSCertHandle CreateOSCert(base::StringPiece der_cert) { 261 static X509Certificate::OSCertHandle CreateOSCert(base::StringPiece der_cert) {
252 return X509Certificate::CreateOSCertHandleFromBytes( 262 return X509Certificate::CreateOSCertHandleFromBytes(
253 const_cast<char*>(der_cert.data()), der_cert.size()); 263 const_cast<char*>(der_cert.data()), der_cert.size());
254 } 264 }
265 #endif
255 266
256 // static 267 // static
257 X509Certificate* X509Certificate::CreateFromDERCertChain( 268 X509Certificate* X509Certificate::CreateFromDERCertChain(
258 const std::vector<base::StringPiece>& der_certs) { 269 const std::vector<base::StringPiece>& der_certs) {
259 if (der_certs.empty()) 270 if (der_certs.empty())
260 return NULL; 271 return NULL;
261 272
262 X509Certificate::OSCertHandles intermediate_ca_certs; 273 X509Certificate::OSCertHandles intermediate_ca_certs;
263 for (size_t i = 1; i < der_certs.size(); i++) { 274 for (size_t i = 1; i < der_certs.size(); i++) {
264 OSCertHandle handle = CreateOSCert(der_certs[i]); 275 OSCertHandle handle = CreateOSCert(der_certs[i]);
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after
690 bool X509Certificate::IsSHA1HashInSortedArray(const SHA1Fingerprint& hash, 701 bool X509Certificate::IsSHA1HashInSortedArray(const SHA1Fingerprint& hash,
691 const uint8* array, 702 const uint8* array,
692 size_t array_byte_len) { 703 size_t array_byte_len) {
693 DCHECK_EQ(0u, array_byte_len % base::SHA1_LENGTH); 704 DCHECK_EQ(0u, array_byte_len % base::SHA1_LENGTH);
694 const unsigned arraylen = array_byte_len / base::SHA1_LENGTH; 705 const unsigned arraylen = array_byte_len / base::SHA1_LENGTH;
695 return NULL != bsearch(hash.data, array, arraylen, base::SHA1_LENGTH, 706 return NULL != bsearch(hash.data, array, arraylen, base::SHA1_LENGTH,
696 CompareSHA1Hashes); 707 CompareSHA1Hashes);
697 } 708 }
698 709
699 } // namespace net 710 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698