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_android.h" | 5 #include "net/cert/cert_verify_proc_android.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
293 | 293 |
294 // Save the verified chain. | 294 // Save the verified chain. |
295 if (!verified_chain.empty()) { | 295 if (!verified_chain.empty()) { |
296 std::vector<base::StringPiece> verified_chain_pieces(verified_chain.size()); | 296 std::vector<base::StringPiece> verified_chain_pieces(verified_chain.size()); |
297 for (size_t i = 0; i < verified_chain.size(); i++) { | 297 for (size_t i = 0; i < verified_chain.size(); i++) { |
298 verified_chain_pieces[i] = base::StringPiece(verified_chain[i]); | 298 verified_chain_pieces[i] = base::StringPiece(verified_chain[i]); |
299 } | 299 } |
300 scoped_refptr<X509Certificate> verified_cert = | 300 scoped_refptr<X509Certificate> verified_cert = |
301 X509Certificate::CreateFromDERCertChain(verified_chain_pieces); | 301 X509Certificate::CreateFromDERCertChain(verified_chain_pieces); |
302 if (verified_cert.get()) | 302 if (verified_cert.get()) |
303 verify_result->verified_cert = verified_cert; | 303 verify_result->verified_cert = std::move(verified_cert); |
| 304 else |
| 305 verify_result->cert_status |= CERT_STATUS_INVALID; |
304 } | 306 } |
305 | 307 |
306 // Extract the public key hashes. | 308 // Extract the public key hashes. |
307 for (size_t i = 0; i < verified_chain.size(); i++) { | 309 for (size_t i = 0; i < verified_chain.size(); i++) { |
308 base::StringPiece spki_bytes; | 310 base::StringPiece spki_bytes; |
309 if (!asn1::ExtractSPKIFromDERCert(verified_chain[i], &spki_bytes)) | 311 if (!asn1::ExtractSPKIFromDERCert(verified_chain[i], &spki_bytes)) { |
| 312 verify_result->cert_status |= CERT_STATUS_INVALID; |
310 continue; | 313 continue; |
| 314 } |
311 | 315 |
312 HashValue sha1(HASH_VALUE_SHA1); | 316 HashValue sha1(HASH_VALUE_SHA1); |
313 base::SHA1HashBytes(reinterpret_cast<const uint8_t*>(spki_bytes.data()), | 317 base::SHA1HashBytes(reinterpret_cast<const uint8_t*>(spki_bytes.data()), |
314 spki_bytes.size(), sha1.data()); | 318 spki_bytes.size(), sha1.data()); |
315 verify_result->public_key_hashes.push_back(sha1); | 319 verify_result->public_key_hashes.push_back(sha1); |
316 | 320 |
317 HashValue sha256(HASH_VALUE_SHA256); | 321 HashValue sha256(HASH_VALUE_SHA256); |
318 crypto::SHA256HashString(spki_bytes, sha256.data(), crypto::kSHA256Length); | 322 crypto::SHA256HashString(spki_bytes, sha256.data(), crypto::kSHA256Length); |
319 verify_result->public_key_hashes.push_back(sha256); | 323 verify_result->public_key_hashes.push_back(sha256); |
320 } | 324 } |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 return ERR_FAILED; | 403 return ERR_FAILED; |
400 } | 404 } |
401 | 405 |
402 if (IsCertStatusError(verify_result->cert_status)) | 406 if (IsCertStatusError(verify_result->cert_status)) |
403 return MapCertStatusToNetError(verify_result->cert_status); | 407 return MapCertStatusToNetError(verify_result->cert_status); |
404 | 408 |
405 return OK; | 409 return OK; |
406 } | 410 } |
407 | 411 |
408 } // namespace net | 412 } // namespace net |
OLD | NEW |