OLD | NEW |
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 "base/crypto/scoped_capi_types.h" | 7 #include "base/crypto/scoped_capi_types.h" |
8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/pickle.h" | 10 #include "base/pickle.h" |
(...skipping 760 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
771 verify_result->cert_status &= ~CERT_STATUS_NO_REVOCATION_MECHANISM; | 771 verify_result->cert_status &= ~CERT_STATUS_NO_REVOCATION_MECHANISM; |
772 | 772 |
773 if (IsCertStatusError(verify_result->cert_status)) | 773 if (IsCertStatusError(verify_result->cert_status)) |
774 return MapCertStatusToNetError(verify_result->cert_status); | 774 return MapCertStatusToNetError(verify_result->cert_status); |
775 | 775 |
776 if (ev_policy_oid && CheckEV(chain_context, ev_policy_oid)) | 776 if (ev_policy_oid && CheckEV(chain_context, ev_policy_oid)) |
777 verify_result->cert_status |= CERT_STATUS_IS_EV; | 777 verify_result->cert_status |= CERT_STATUS_IS_EV; |
778 return OK; | 778 return OK; |
779 } | 779 } |
780 | 780 |
| 781 bool X509Certificate::GetDEREncoded(std::string* encoded) { |
| 782 if (!cert_handle_->pbCertEncoded || !cert_handle_->cbCertEncoded) |
| 783 return false; |
| 784 encoded->clear(); |
| 785 encoded->append(reinterpret_cast<char*>(cert_handle_->pbCertEncoded), |
| 786 cert_handle_->cbCertEncoded); |
| 787 return true; |
| 788 } |
| 789 |
781 // Returns true if the certificate is an extended-validation certificate. | 790 // Returns true if the certificate is an extended-validation certificate. |
782 // | 791 // |
783 // This function checks the certificatePolicies extensions of the | 792 // This function checks the certificatePolicies extensions of the |
784 // certificates in the certificate chain according to Section 7 (pp. 11-12) | 793 // certificates in the certificate chain according to Section 7 (pp. 11-12) |
785 // of the EV Certificate Guidelines Version 1.0 at | 794 // of the EV Certificate Guidelines Version 1.0 at |
786 // http://cabforum.org/EV_Certificate_Guidelines.pdf. | 795 // http://cabforum.org/EV_Certificate_Guidelines.pdf. |
787 bool X509Certificate::CheckEV(PCCERT_CHAIN_CONTEXT chain_context, | 796 bool X509Certificate::CheckEV(PCCERT_CHAIN_CONTEXT chain_context, |
788 const char* policy_oid) const { | 797 const char* policy_oid) const { |
789 DCHECK(chain_context->cChain != 0); | 798 DCHECK(chain_context->cChain != 0); |
790 // If the cert doesn't match any of the policies, the | 799 // If the cert doesn't match any of the policies, the |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
887 DWORD sha1_size = sizeof(sha1.data); | 896 DWORD sha1_size = sizeof(sha1.data); |
888 rv = CryptHashCertificate(NULL, CALG_SHA1, 0, cert->pbCertEncoded, | 897 rv = CryptHashCertificate(NULL, CALG_SHA1, 0, cert->pbCertEncoded, |
889 cert->cbCertEncoded, sha1.data, &sha1_size); | 898 cert->cbCertEncoded, sha1.data, &sha1_size); |
890 DCHECK(rv && sha1_size == sizeof(sha1.data)); | 899 DCHECK(rv && sha1_size == sizeof(sha1.data)); |
891 if (!rv) | 900 if (!rv) |
892 memset(sha1.data, 0, sizeof(sha1.data)); | 901 memset(sha1.data, 0, sizeof(sha1.data)); |
893 return sha1; | 902 return sha1; |
894 } | 903 } |
895 | 904 |
896 } // namespace net | 905 } // namespace net |
OLD | NEW |