Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "blimp/net/exact_match_cert_verifier.h" | |
| 6 | |
| 7 #include "base/callback.h" | |
| 8 #include "base/macros.h" | |
| 9 #include "base/memory/scoped_ptr.h" | |
| 10 #include "net/base/net_errors.h" | |
| 11 #include "net/cert/cert_verifier.h" | |
| 12 #include "net/cert/cert_verify_result.h" | |
| 13 #include "net/cert/x509_certificate.h" | |
| 14 | |
| 15 namespace blimp { | |
| 16 | |
| 17 ExactMatchCertVerifier::ExactMatchCertVerifier( | |
| 18 const scoped_refptr<net::X509Certificate>& engine_cert) | |
| 19 : engine_cert_(engine_cert) {} | |
| 20 | |
| 21 ExactMatchCertVerifier::~ExactMatchCertVerifier() {} | |
| 22 | |
| 23 int ExactMatchCertVerifier::Verify(net::X509Certificate* cert, | |
| 24 const std::string& hostname, | |
| 25 const std::string& ocsp_response, | |
| 26 int flags, | |
| 27 net::CRLSet* crl_set, | |
| 28 net::CertVerifyResult* verify_result, | |
| 29 const net::CompletionCallback& callback, | |
| 30 scoped_ptr<Request>* out_req, | |
| 31 const net::BoundNetLog& net_log) { | |
| 32 verify_result->Reset(); | |
| 33 | |
| 34 if (!cert->Equals(engine_cert_.get())) { | |
| 35 verify_result->cert_status = net::CERT_STATUS_INVALID; | |
| 36 return net::ERR_CERT_INVALID; | |
| 37 } | |
| 38 | |
| 39 verify_result->verified_cert = cert; | |
|
Ryan Sleevi
2016/02/23 00:49:45
Line 39 should be before line 34.
Kevin M
2016/02/23 01:58:26
Done.
| |
| 40 | |
| 41 // Attach hashes of |cert| to VerifyResult. | |
| 42 net::SHA1HashValue sha1_hash; | |
| 43 sha1_hash = | |
| 44 net::X509Certificate::CalculateFingerprint(cert->os_cert_handle()); | |
| 45 verify_result->public_key_hashes.push_back(net::HashValue(sha1_hash)); | |
| 46 | |
| 47 net::SHA256HashValue sha256_hash; | |
| 48 sha256_hash = | |
| 49 net::X509Certificate::CalculateFingerprint256(cert->os_cert_handle()); | |
| 50 verify_result->public_key_hashes.push_back(net::HashValue(sha256_hash)); | |
| 51 | |
| 52 return net::OK; | |
| 53 } | |
| 54 | |
| 55 } // namespace blimp | |
| OLD | NEW |