OLD | NEW |
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2016 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_ios.h" | 5 #include "net/cert/cert_verify_proc_ios.h" |
6 | 6 |
7 #include <CommonCrypto/CommonDigest.h> | 7 #include <CommonCrypto/CommonDigest.h> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/mac/scoped_cftyperef.h" | 10 #include "base/mac/scoped_cftyperef.h" |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 | 97 |
98 trust_ref->swap(scoped_tmp_trust); | 98 trust_ref->swap(scoped_tmp_trust); |
99 *trust_result = tmp_trust_result; | 99 *trust_result = tmp_trust_result; |
100 verified_chain->reset(tmp_verified_chain.release()); | 100 verified_chain->reset(tmp_verified_chain.release()); |
101 return OK; | 101 return OK; |
102 } | 102 } |
103 | 103 |
104 void GetCertChainInfo(CFArrayRef cert_chain, CertVerifyResult* verify_result) { | 104 void GetCertChainInfo(CFArrayRef cert_chain, CertVerifyResult* verify_result) { |
105 DCHECK_LT(0, CFArrayGetCount(cert_chain)); | 105 DCHECK_LT(0, CFArrayGetCount(cert_chain)); |
106 | 106 |
107 verify_result->has_md2 = false; | |
108 verify_result->has_md4 = false; | |
109 verify_result->has_md5 = false; | |
110 verify_result->has_sha1 = false; | |
111 verify_result->has_sha1_leaf = false; | |
112 | |
113 SecCertificateRef verified_cert = nullptr; | 107 SecCertificateRef verified_cert = nullptr; |
114 std::vector<SecCertificateRef> verified_chain; | 108 std::vector<SecCertificateRef> verified_chain; |
115 for (CFIndex i = 0, count = CFArrayGetCount(cert_chain); i < count; ++i) { | 109 for (CFIndex i = 0, count = CFArrayGetCount(cert_chain); i < count; ++i) { |
116 SecCertificateRef chain_cert = reinterpret_cast<SecCertificateRef>( | 110 SecCertificateRef chain_cert = reinterpret_cast<SecCertificateRef>( |
117 const_cast<void*>(CFArrayGetValueAtIndex(cert_chain, i))); | 111 const_cast<void*>(CFArrayGetValueAtIndex(cert_chain, i))); |
118 if (i == 0) { | 112 if (i == 0) { |
119 verified_cert = chain_cert; | 113 verified_cert = chain_cert; |
120 } else { | 114 } else { |
121 verified_chain.push_back(chain_cert); | 115 verified_chain.push_back(chain_cert); |
122 } | 116 } |
(...skipping 12 matching lines...) Expand all Loading... |
135 | 129 |
136 HashValue sha256(HASH_VALUE_SHA256); | 130 HashValue sha256(HASH_VALUE_SHA256); |
137 CC_SHA256(spki_bytes.data(), spki_bytes.size(), sha256.data()); | 131 CC_SHA256(spki_bytes.data(), spki_bytes.size(), sha256.data()); |
138 verify_result->public_key_hashes.push_back(sha256); | 132 verify_result->public_key_hashes.push_back(sha256); |
139 | 133 |
140 // Ignore the signature algorithm for the trust anchor. | 134 // Ignore the signature algorithm for the trust anchor. |
141 if ((verify_result->cert_status & CERT_STATUS_AUTHORITY_INVALID) == 0 && | 135 if ((verify_result->cert_status & CERT_STATUS_AUTHORITY_INVALID) == 0 && |
142 i == count - 1) { | 136 i == count - 1) { |
143 continue; | 137 continue; |
144 } | 138 } |
145 FillCertVerifyResultWeakSignature(chain_cert, i == 0, verify_result); | |
146 } | 139 } |
147 if (!verified_cert) { | 140 if (!verified_cert) { |
148 NOTREACHED(); | 141 NOTREACHED(); |
149 return; | 142 return; |
150 } | 143 } |
151 | 144 |
152 verify_result->verified_cert = | 145 verify_result->verified_cert = |
153 X509Certificate::CreateFromHandle(verified_cert, verified_chain); | 146 X509Certificate::CreateFromHandle(verified_cert, verified_chain); |
154 } | 147 } |
155 | 148 |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 | 274 |
282 verify_result->is_issued_by_known_root = false; | 275 verify_result->is_issued_by_known_root = false; |
283 | 276 |
284 if (IsCertStatusError(verify_result->cert_status)) | 277 if (IsCertStatusError(verify_result->cert_status)) |
285 return MapCertStatusToNetError(verify_result->cert_status); | 278 return MapCertStatusToNetError(verify_result->cert_status); |
286 | 279 |
287 return OK; | 280 return OK; |
288 } | 281 } |
289 | 282 |
290 } // namespace net | 283 } // namespace net |
OLD | NEW |