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 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/pickle.h" | 9 #include "base/pickle.h" |
10 #include "base/sha1.h" | 10 #include "base/sha1.h" |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 return OK; | 88 return OK; |
89 default: | 89 default: |
90 LOG(WARNING) << "Unknown error " << err << " mapped to net::ERR_FAILED"; | 90 LOG(WARNING) << "Unknown error " << err << " mapped to net::ERR_FAILED"; |
91 return ERR_FAILED; | 91 return ERR_FAILED; |
92 } | 92 } |
93 } | 93 } |
94 | 94 |
95 // Map the errors in the chain_context->TrustStatus.dwErrorStatus returned by | 95 // Map the errors in the chain_context->TrustStatus.dwErrorStatus returned by |
96 // CertGetCertificateChain to our certificate status flags. | 96 // CertGetCertificateChain to our certificate status flags. |
97 int MapCertChainErrorStatusToCertStatus(DWORD error_status) { | 97 int MapCertChainErrorStatusToCertStatus(DWORD error_status) { |
98 int cert_status = 0; | 98 CertStatus cert_status = CERT_STATUS_NO_ERROR; |
99 | 99 |
100 // We don't include CERT_TRUST_IS_NOT_TIME_NESTED because it's obsolete and | 100 // We don't include CERT_TRUST_IS_NOT_TIME_NESTED because it's obsolete and |
101 // we wouldn't consider it an error anyway | 101 // we wouldn't consider it an error anyway |
102 const DWORD kDateInvalidErrors = CERT_TRUST_IS_NOT_TIME_VALID | | 102 const DWORD kDateInvalidErrors = CERT_TRUST_IS_NOT_TIME_VALID | |
103 CERT_TRUST_CTL_IS_NOT_TIME_VALID; | 103 CERT_TRUST_CTL_IS_NOT_TIME_VALID; |
104 if (error_status & kDateInvalidErrors) | 104 if (error_status & kDateInvalidErrors) |
105 cert_status |= CERT_STATUS_DATE_INVALID; | 105 cert_status |= CERT_STATUS_DATE_INVALID; |
106 | 106 |
107 const DWORD kAuthorityInvalidErrors = CERT_TRUST_IS_UNTRUSTED_ROOT | | 107 const DWORD kAuthorityInvalidErrors = CERT_TRUST_IS_UNTRUSTED_ROOT | |
108 CERT_TRUST_IS_EXPLICIT_DISTRUST | | 108 CERT_TRUST_IS_EXPLICIT_DISTRUST | |
(...skipping 942 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1051 if (!CertSerializeCertificateStoreElement(cert_handle, 0, &buffer[0], | 1051 if (!CertSerializeCertificateStoreElement(cert_handle, 0, &buffer[0], |
1052 &length)) { | 1052 &length)) { |
1053 return false; | 1053 return false; |
1054 } | 1054 } |
1055 | 1055 |
1056 return pickle->WriteData(reinterpret_cast<const char*>(&buffer[0]), | 1056 return pickle->WriteData(reinterpret_cast<const char*>(&buffer[0]), |
1057 length); | 1057 length); |
1058 } | 1058 } |
1059 | 1059 |
1060 } // namespace net | 1060 } // namespace net |
OLD | NEW |