Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(83)

Side by Side Diff: chrome/browser/ssl/ignore_errors_cert_verifier.h

Issue 2753123002: Add --ignore-certificate-errors-spki-list switch and UMA histogram. (Closed)
Patch Set: Add --ignore-certificate-errors-spki-list switch and UMA histogram. Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2017 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 #ifndef CHROME_BROWSER_SSL_IGNORE_ERRORS_CERT_VERIFIER_H_
6 #define CHROME_BROWSER_SSL_IGNORE_ERRORS_CERT_VERIFIER_H_
7
8 #include <memory>
9 #include <string>
10 #include <vector>
11
12 #include "base/containers/flat_set.h"
13 #include "net/cert/cert_verifier.h"
14
15 namespace net {
16 struct SHA256HashValue;
17 class SHA256HashValueLessThan;
18 } // namespace net
19
20 // IgnoreErrorsCertVerifier wraps another CertVerifier in order to ignore
21 // verification errors from certificate chains that match a whitelist of SPKI
22 // fingerprints.
23 class NET_EXPORT IgnoreErrorsCertVerifier : public net::CertVerifier {
24 public:
25 // SPKIHashSet is a set of SHA-256 SPKI fingerprints (RFC 7469, Section 2.4).
26 using SPKIHashSet =
27 base::flat_set<net::SHA256HashValue, net::SHA256HashValueLessThan>;
28
29 // MakeWhitelist converts a vector of Base64-encoded SHA-256 SPKI fingerprints
30 // into an SPKIHashSet. Invalid fingerprints are logged and skipped.
31 static SPKIHashSet MakeWhitelist(
32 const std::vector<std::string>& fingerprints);
33
34 IgnoreErrorsCertVerifier(std::unique_ptr<net::CertVerifier> verifier,
35 SPKIHashSet whitelist);
36
37 ~IgnoreErrorsCertVerifier() override;
38
39 // Verify skips certificate verification and returns OK if any of the
40 // certificates from the chain in |params| match one of the SPKI fingerprints
41 // from the whitelist. Otherwise, it invokes Verify on the wrapped verifier
42 // and returns the result.
43 int Verify(const RequestParams& params,
44 net::CRLSet* crl_set,
45 net::CertVerifyResult* verify_result,
46 const net::CompletionCallback& callback,
47 std::unique_ptr<Request>* out_req,
48 const net::NetLogWithSource& net_log) override;
49
50 private:
51 std::unique_ptr<net::CertVerifier> verifier_;
52 SPKIHashSet whitelist_;
53 };
54
55 #endif // CHROME_BROWSER_SSL_IGNORE_ERRORS_CERT_VERIFIER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698