Chromium Code Reviews| 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/cert_verify_proc_win.h" | 5 #include "net/cert/cert_verify_proc_win.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/debug/alias.h" | |
| 12 #include "base/debug/dump_without_crashing.h" | |
| 11 #include "base/memory/free_deleter.h" | 13 #include "base/memory/free_deleter.h" |
| 12 #include "base/metrics/histogram_macros.h" | 14 #include "base/metrics/histogram_macros.h" |
| 13 #include "base/sha1.h" | 15 #include "base/sha1.h" |
| 14 #include "base/strings/string_util.h" | 16 #include "base/strings/string_util.h" |
| 15 #include "base/strings/utf_string_conversions.h" | 17 #include "base/strings/utf_string_conversions.h" |
| 16 #include "base/threading/thread_local.h" | 18 #include "base/threading/thread_local.h" |
| 19 #include "base/time/time.h" | |
| 17 #include "crypto/capi_util.h" | 20 #include "crypto/capi_util.h" |
| 18 #include "crypto/scoped_capi_types.h" | 21 #include "crypto/scoped_capi_types.h" |
| 19 #include "crypto/sha2.h" | 22 #include "crypto/sha2.h" |
| 20 #include "net/base/net_errors.h" | 23 #include "net/base/net_errors.h" |
| 21 #include "net/cert/asn1_util.h" | 24 #include "net/cert/asn1_util.h" |
| 22 #include "net/cert/cert_status_flags.h" | 25 #include "net/cert/cert_status_flags.h" |
| 23 #include "net/cert/cert_verifier.h" | 26 #include "net/cert/cert_verifier.h" |
| 24 #include "net/cert/cert_verify_result.h" | 27 #include "net/cert/cert_verify_result.h" |
| 25 #include "net/cert/crl_set.h" | 28 #include "net/cert/crl_set.h" |
| 26 #include "net/cert/ev_root_ca_metadata.h" | 29 #include "net/cert/ev_root_ca_metadata.h" |
| (...skipping 861 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 888 } | 891 } |
| 889 | 892 |
| 890 class ScopedThreadLocalCRLSet { | 893 class ScopedThreadLocalCRLSet { |
| 891 public: | 894 public: |
| 892 explicit ScopedThreadLocalCRLSet(CRLSet* crl_set) { | 895 explicit ScopedThreadLocalCRLSet(CRLSet* crl_set) { |
| 893 g_revocation_injector.Get().SetCRLSet(crl_set); | 896 g_revocation_injector.Get().SetCRLSet(crl_set); |
| 894 } | 897 } |
| 895 ~ScopedThreadLocalCRLSet() { g_revocation_injector.Get().SetCRLSet(nullptr); } | 898 ~ScopedThreadLocalCRLSet() { g_revocation_injector.Get().SetCRLSet(nullptr); } |
| 896 }; | 899 }; |
| 897 | 900 |
| 901 // Sends a crash dump (without actually crashing) when the system time | |
| 902 // falls within the validity period of every certificate in | |
| 903 // |verified_cert|'s chain. This is to investigate reports of odd | |
| 904 // certificate errors that report ERR_CERT_DATE_INVALID when the | |
| 905 // certificate chain's dates appear to be valid. | |
| 906 // | |
| 907 // TODO(estark): remove this after obtaining diagnostic data from | |
| 908 // Canary. https://crbug.com/672906 | |
| 909 void MaybeDumpCertificateDateError( | |
| 910 const scoped_refptr<X509Certificate>& verified_cert, | |
| 911 DWORD error_status) { | |
| 912 const base::Time now = base::Time::NowFromSystemTime(); | |
| 913 DWORD temp_error_status = error_status; | |
| 914 base::debug::Alias(&temp_error_status); | |
|
Will Harris
2016/12/09 21:33:05
base::debug::Alias requires you to open up the cra
Ryan Sleevi
2016/12/09 21:35:53
Seems like 913-914 should be moved to 932, since t
estark
2016/12/09 22:57:38
Done.
estark
2016/12/09 22:57:38
Done.
| |
| 915 // If the leaf certificate is expired or not yet valid, nothing is odd. | |
| 916 if (now >= verified_cert->valid_expiry() || | |
| 917 now <= verified_cert->valid_start()) { | |
| 918 return; | |
| 919 } | |
| 920 // Repeat the check for the rest of the certificates in the chain; if | |
| 921 // any of them is expired or not yet valid, nothing is odd. | |
| 922 X509Certificate::OSCertHandles intermediates = | |
| 923 verified_cert->GetIntermediateCertificates(); | |
| 924 for (const auto& intermediate : intermediates) { | |
| 925 base::Time valid_start = | |
| 926 base::Time::FromFileTime(intermediate->pCertInfo->NotBefore); | |
| 927 base::Time valid_expiry = | |
| 928 base::Time::FromFileTime(intermediate->pCertInfo->NotAfter); | |
| 929 if (now >= valid_expiry || now <= valid_start) | |
| 930 return; | |
| 931 } | |
| 932 // None of the certificates in the chain appear to be expired or | |
| 933 // not-yet-valid, so send a crash dump for diagnostics. | |
| 934 base::debug::DumpWithoutCrashing(); | |
|
Will Harris
2016/12/09 21:33:05
can you make this canary only?
estark
2016/12/09 22:57:38
Oh, sorry, I forgot to mention that -- I couldn't
Will Harris
2016/12/10 00:35:07
ah yes that's right you can't depend on chrome/ fr
| |
| 935 } | |
| 936 | |
| 898 } // namespace | 937 } // namespace |
| 899 | 938 |
| 900 CertVerifyProcWin::CertVerifyProcWin() {} | 939 CertVerifyProcWin::CertVerifyProcWin() {} |
| 901 | 940 |
| 902 CertVerifyProcWin::~CertVerifyProcWin() {} | 941 CertVerifyProcWin::~CertVerifyProcWin() {} |
| 903 | 942 |
| 904 bool CertVerifyProcWin::SupportsAdditionalTrustAnchors() const { | 943 bool CertVerifyProcWin::SupportsAdditionalTrustAnchors() const { |
| 905 return false; | 944 return false; |
| 906 } | 945 } |
| 907 | 946 |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1163 CERT_TRUST_IS_OFFLINE_REVOCATION) { | 1202 CERT_TRUST_IS_OFFLINE_REVOCATION) { |
| 1164 verify_result->cert_status |= CERT_STATUS_REVOKED; | 1203 verify_result->cert_status |= CERT_STATUS_REVOKED; |
| 1165 } | 1204 } |
| 1166 } | 1205 } |
| 1167 | 1206 |
| 1168 ScopedPCCERT_CHAIN_CONTEXT scoped_chain_context(chain_context); | 1207 ScopedPCCERT_CHAIN_CONTEXT scoped_chain_context(chain_context); |
| 1169 | 1208 |
| 1170 verify_result->cert_status |= MapCertChainErrorStatusToCertStatus( | 1209 verify_result->cert_status |= MapCertChainErrorStatusToCertStatus( |
| 1171 chain_context->TrustStatus.dwErrorStatus); | 1210 chain_context->TrustStatus.dwErrorStatus); |
| 1172 | 1211 |
| 1212 // Send some diagnostic data in the event of certificate date errors | |
| 1213 // that occur on chains with validity periods that are valid according | |
| 1214 // to the system clock. | |
| 1215 // TODO(estark): remove this after obtaining diagnostic data from | |
| 1216 // Canary. https://crbug.com/672906 | |
| 1217 if (verify_result->cert_status & CERT_STATUS_DATE_INVALID) { | |
| 1218 MaybeDumpCertificateDateError(verify_result->verified_cert, | |
| 1219 chain_context->TrustStatus.dwErrorStatus); | |
|
Ryan Sleevi
2016/12/09 21:35:53
I'd recommend you grab both dwErrorStatus and dwIn
estark
2016/12/09 22:57:38
Done.
| |
| 1220 } | |
| 1221 | |
| 1173 // Flag certificates that have a Subject common name with a NULL character. | 1222 // Flag certificates that have a Subject common name with a NULL character. |
| 1174 if (CertSubjectCommonNameHasNull(cert_handle)) | 1223 if (CertSubjectCommonNameHasNull(cert_handle)) |
| 1175 verify_result->cert_status |= CERT_STATUS_INVALID; | 1224 verify_result->cert_status |= CERT_STATUS_INVALID; |
| 1176 | 1225 |
| 1177 base::string16 hostname16 = base::ASCIIToUTF16(hostname); | 1226 base::string16 hostname16 = base::ASCIIToUTF16(hostname); |
| 1178 | 1227 |
| 1179 SSL_EXTRA_CERT_CHAIN_POLICY_PARA extra_policy_para; | 1228 SSL_EXTRA_CERT_CHAIN_POLICY_PARA extra_policy_para; |
| 1180 memset(&extra_policy_para, 0, sizeof(extra_policy_para)); | 1229 memset(&extra_policy_para, 0, sizeof(extra_policy_para)); |
| 1181 extra_policy_para.cbSize = sizeof(extra_policy_para); | 1230 extra_policy_para.cbSize = sizeof(extra_policy_para); |
| 1182 extra_policy_para.dwAuthType = AUTHTYPE_SERVER; | 1231 extra_policy_para.dwAuthType = AUTHTYPE_SERVER; |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1236 return MapCertStatusToNetError(verify_result->cert_status); | 1285 return MapCertStatusToNetError(verify_result->cert_status); |
| 1237 | 1286 |
| 1238 if (ev_policy_oid && | 1287 if (ev_policy_oid && |
| 1239 CheckEV(chain_context, rev_checking_enabled, ev_policy_oid)) { | 1288 CheckEV(chain_context, rev_checking_enabled, ev_policy_oid)) { |
| 1240 verify_result->cert_status |= CERT_STATUS_IS_EV; | 1289 verify_result->cert_status |= CERT_STATUS_IS_EV; |
| 1241 } | 1290 } |
| 1242 return OK; | 1291 return OK; |
| 1243 } | 1292 } |
| 1244 | 1293 |
| 1245 } // namespace net | 1294 } // namespace net |
| OLD | NEW |