OLD | NEW |
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 #define PRArenaPool PLArenaPool // Required by <blapi.h>. | 7 #define PRArenaPool PLArenaPool // Required by <blapi.h>. |
8 #include <blapi.h> // Implement CalculateChainFingerprint() with NSS. | 8 #include <blapi.h> // Implement CalculateChainFingerprint() with NSS. |
9 | 9 |
10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
(...skipping 946 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
957 return MapCertStatusToNetError(verify_result->cert_status); | 957 return MapCertStatusToNetError(verify_result->cert_status); |
958 | 958 |
959 AppendPublicKeyHashes(chain_context, &verify_result->public_key_hashes); | 959 AppendPublicKeyHashes(chain_context, &verify_result->public_key_hashes); |
960 verify_result->is_issued_by_known_root = IsIssuedByKnownRoot(chain_context); | 960 verify_result->is_issued_by_known_root = IsIssuedByKnownRoot(chain_context); |
961 | 961 |
962 if (ev_policy_oid && CheckEV(chain_context, ev_policy_oid)) | 962 if (ev_policy_oid && CheckEV(chain_context, ev_policy_oid)) |
963 verify_result->cert_status |= CERT_STATUS_IS_EV; | 963 verify_result->cert_status |= CERT_STATUS_IS_EV; |
964 return OK; | 964 return OK; |
965 } | 965 } |
966 | 966 |
967 bool X509Certificate::GetDEREncoded(std::string* encoded) { | 967 // static |
968 if (!cert_handle_->pbCertEncoded || !cert_handle_->cbCertEncoded) | 968 bool X509Certificate::GetDEREncoded(X509Certificate::OSCertHandle cert_handle, |
| 969 std::string* encoded) { |
| 970 if (!cert_handle->pbCertEncoded || !cert_handle->cbCertEncoded) |
969 return false; | 971 return false; |
970 encoded->clear(); | 972 encoded->assign(reinterpret_cast<char*>(cert_handle->pbCertEncoded), |
971 encoded->append(reinterpret_cast<char*>(cert_handle_->pbCertEncoded), | 973 cert_handle->cbCertEncoded); |
972 cert_handle_->cbCertEncoded); | |
973 return true; | 974 return true; |
974 } | 975 } |
975 | 976 |
976 // Returns true if the certificate is an extended-validation certificate. | 977 // Returns true if the certificate is an extended-validation certificate. |
977 // | 978 // |
978 // This function checks the certificatePolicies extensions of the | 979 // This function checks the certificatePolicies extensions of the |
979 // certificates in the certificate chain according to Section 7 (pp. 11-12) | 980 // certificates in the certificate chain according to Section 7 (pp. 11-12) |
980 // of the EV Certificate Guidelines Version 1.0 at | 981 // of the EV Certificate Guidelines Version 1.0 at |
981 // http://cabforum.org/EV_Certificate_Guidelines.pdf. | 982 // http://cabforum.org/EV_Certificate_Guidelines.pdf. |
982 bool X509Certificate::CheckEV(PCCERT_CHAIN_CONTEXT chain_context, | 983 bool X509Certificate::CheckEV(PCCERT_CHAIN_CONTEXT chain_context, |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1135 if (!CertSerializeCertificateStoreElement(cert_handle, 0, &buffer[0], | 1136 if (!CertSerializeCertificateStoreElement(cert_handle, 0, &buffer[0], |
1136 &length)) { | 1137 &length)) { |
1137 return false; | 1138 return false; |
1138 } | 1139 } |
1139 | 1140 |
1140 return pickle->WriteData(reinterpret_cast<const char*>(&buffer[0]), | 1141 return pickle->WriteData(reinterpret_cast<const char*>(&buffer[0]), |
1141 length); | 1142 length); |
1142 } | 1143 } |
1143 | 1144 |
1144 } // namespace net | 1145 } // namespace net |
OLD | NEW |