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 scoped_refptr<net::X509Certificate> engine_cert) |
| 19 : engine_cert_(std::move(engine_cert)) { |
| 20 DCHECK(engine_cert); |
| 21 |
| 22 net::SHA1HashValue sha1_hash; |
| 23 sha1_hash = net::X509Certificate::CalculateFingerprint( |
| 24 engine_cert_->os_cert_handle()); |
| 25 engine_cert_hashes_.push_back(net::HashValue(sha1_hash)); |
| 26 |
| 27 net::SHA256HashValue sha256_hash; |
| 28 sha256_hash = net::X509Certificate::CalculateFingerprint256( |
| 29 engine_cert_->os_cert_handle()); |
| 30 engine_cert_hashes_.push_back(net::HashValue(sha256_hash)); |
| 31 } |
| 32 |
| 33 ExactMatchCertVerifier::~ExactMatchCertVerifier() {} |
| 34 |
| 35 int ExactMatchCertVerifier::Verify(net::X509Certificate* cert, |
| 36 const std::string& hostname, |
| 37 const std::string& ocsp_response, |
| 38 int flags, |
| 39 net::CRLSet* crl_set, |
| 40 net::CertVerifyResult* verify_result, |
| 41 const net::CompletionCallback& callback, |
| 42 scoped_ptr<Request>* out_req, |
| 43 const net::BoundNetLog& net_log) { |
| 44 verify_result->Reset(); |
| 45 verify_result->verified_cert = engine_cert_; |
| 46 |
| 47 if (!cert->Equals(engine_cert_.get())) { |
| 48 verify_result->cert_status = net::CERT_STATUS_INVALID; |
| 49 return net::ERR_CERT_INVALID; |
| 50 } |
| 51 |
| 52 verify_result->public_key_hashes = engine_cert_hashes_; |
| 53 return net::OK; |
| 54 } |
| 55 |
| 56 } // namespace blimp |
OLD | NEW |