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 <memory> | |
8 | |
9 #include "base/callback.h" | |
10 #include "base/macros.h" | |
11 #include "net/base/net_errors.h" | |
12 #include "net/cert/cert_verifier.h" | |
13 #include "net/cert/cert_verify_result.h" | |
14 #include "net/cert/x509_certificate.h" | |
15 | |
16 namespace blimp { | |
17 | |
18 ExactMatchCertVerifier::ExactMatchCertVerifier( | |
19 scoped_refptr<net::X509Certificate> engine_cert) | |
20 : engine_cert_(std::move(engine_cert)) { | |
21 DCHECK(engine_cert_); | |
22 | |
23 net::SHA256HashValue sha256_hash; | |
24 sha256_hash = net::X509Certificate::CalculateFingerprint256( | |
25 engine_cert_->os_cert_handle()); | |
26 engine_cert_hashes_.push_back(net::HashValue(sha256_hash)); | |
27 } | |
28 | |
29 ExactMatchCertVerifier::~ExactMatchCertVerifier() {} | |
30 | |
31 int ExactMatchCertVerifier::Verify(const RequestParams& params, | |
32 net::CRLSet* crl_set, | |
33 net::CertVerifyResult* verify_result, | |
34 const net::CompletionCallback& callback, | |
35 std::unique_ptr<Request>* out_req, | |
36 const net::NetLogWithSource& net_log) { | |
37 verify_result->Reset(); | |
38 verify_result->verified_cert = engine_cert_; | |
39 | |
40 if (!params.certificate()->Equals(engine_cert_.get())) { | |
41 verify_result->cert_status = net::CERT_STATUS_INVALID; | |
42 return net::ERR_CERT_INVALID; | |
43 } | |
44 | |
45 verify_result->public_key_hashes = engine_cert_hashes_; | |
46 return net::OK; | |
47 } | |
48 | |
49 } // namespace blimp | |
OLD | NEW |