OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/cert/x509_certificate.h" | 5 #include "net/cert/x509_certificate.h" |
6 | 6 |
7 #include <CommonCrypto/CommonDigest.h> | 7 #include <CommonCrypto/CommonDigest.h> |
8 #include <CoreServices/CoreServices.h> | 8 #include <CoreServices/CoreServices.h> |
9 #include <Security/Security.h> | 9 #include <Security/Security.h> |
10 | 10 |
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
490 void X509Certificate::GetPublicKeyInfo(OSCertHandle cert_handle, | 490 void X509Certificate::GetPublicKeyInfo(OSCertHandle cert_handle, |
491 size_t* size_bits, | 491 size_t* size_bits, |
492 PublicKeyType* type) { | 492 PublicKeyType* type) { |
493 // Since we might fail, set the output parameters to default values first. | 493 // Since we might fail, set the output parameters to default values first. |
494 *type = kPublicKeyTypeUnknown; | 494 *type = kPublicKeyTypeUnknown; |
495 *size_bits = 0; | 495 *size_bits = 0; |
496 | 496 |
497 SecKeyRef key; | 497 SecKeyRef key; |
498 OSStatus status = SecCertificateCopyPublicKey(cert_handle, &key); | 498 OSStatus status = SecCertificateCopyPublicKey(cert_handle, &key); |
499 if (status) { | 499 if (status) { |
500 NOTREACHED() << "SecCertificateCopyPublicKey failed: " << status; | 500 // SecCertificateCopyPublicKey may fail if the certificate has an invalid |
| 501 // key. See https://crbug.com/472291. |
| 502 LOG(WARNING) << "SecCertificateCopyPublicKey failed: " << status; |
501 return; | 503 return; |
502 } | 504 } |
503 ScopedCFTypeRef<SecKeyRef> scoped_key(key); | 505 ScopedCFTypeRef<SecKeyRef> scoped_key(key); |
504 | 506 |
505 const CSSM_KEY* cssm_key; | 507 const CSSM_KEY* cssm_key; |
506 status = SecKeyGetCSSMKey(key, &cssm_key); | 508 status = SecKeyGetCSSMKey(key, &cssm_key); |
507 if (status) { | 509 if (status) { |
508 NOTREACHED() << "SecKeyGetCSSMKey failed: " << status; | 510 NOTREACHED() << "SecKeyGetCSSMKey failed: " << status; |
509 return; | 511 return; |
510 } | 512 } |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
562 status = SecCertificateGetData(cert_handle, &cert_data); | 564 status = SecCertificateGetData(cert_handle, &cert_data); |
563 if (status) | 565 if (status) |
564 return false; | 566 return false; |
565 | 567 |
566 if (CSSM_CL_CertVerify(cl_handle, 0, &cert_data, &cert_data, NULL, 0)) | 568 if (CSSM_CL_CertVerify(cl_handle, 0, &cert_data, &cert_data, NULL, 0)) |
567 return false; | 569 return false; |
568 return true; | 570 return true; |
569 } | 571 } |
570 | 572 |
571 } // namespace net | 573 } // namespace net |
OLD | NEW |