| 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 <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include <openssl/sha.h> | 9 #include <openssl/sha.h> |
| 10 | 10 |
| (...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 457 valid_issuers)) { | 457 valid_issuers)) { |
| 458 return true; | 458 return true; |
| 459 } | 459 } |
| 460 } | 460 } |
| 461 | 461 |
| 462 return false; | 462 return false; |
| 463 } | 463 } |
| 464 | 464 |
| 465 // static | 465 // static |
| 466 bool X509Certificate::IsSelfSigned(OSCertHandle cert_handle) { | 466 bool X509Certificate::IsSelfSigned(OSCertHandle cert_handle) { |
| 467 return !!CryptVerifyCertificateSignatureEx( | 467 bool valid_signature = !!CryptVerifyCertificateSignatureEx( |
| 468 NULL, | 468 NULL, X509_ASN_ENCODING, CRYPT_VERIFY_CERT_SIGN_SUBJECT_CERT, |
| 469 X509_ASN_ENCODING, | |
| 470 CRYPT_VERIFY_CERT_SIGN_SUBJECT_CERT, | |
| 471 reinterpret_cast<void*>(const_cast<PCERT_CONTEXT>(cert_handle)), | 469 reinterpret_cast<void*>(const_cast<PCERT_CONTEXT>(cert_handle)), |
| 472 CRYPT_VERIFY_CERT_SIGN_ISSUER_CERT, | 470 CRYPT_VERIFY_CERT_SIGN_ISSUER_CERT, |
| 473 reinterpret_cast<void*>(const_cast<PCERT_CONTEXT>(cert_handle)), | 471 reinterpret_cast<void*>(const_cast<PCERT_CONTEXT>(cert_handle)), 0, NULL); |
| 474 0, | 472 if (!valid_signature) |
| 475 NULL); | 473 return false; |
| 474 return !!CertCompareCertificateName(X509_ASN_ENCODING, |
| 475 &cert_handle->pCertInfo->Subject, |
| 476 &cert_handle->pCertInfo->Issuer); |
| 476 } | 477 } |
| 477 | 478 |
| 478 } // namespace net | 479 } // namespace net |
| OLD | NEW |