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

Side by Side Diff: android_webview/browser/aw_ssl_host_state_delegate.h

Issue 794023002: Remember user's decisions on SSL errors. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Implement with SSLHostStateDelegate Created 6 years 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) 2012 The Chromium Authors. All rights reserved.
jww 2014/12/12 01:48:41 nit: I think this should be "Copyright (c) 2014"
hush (inactive) 2014/12/12 02:42:37 Done.
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 ANDROID_WEBVIEW_BROWSER_AW_SSL_HOST_STATE_DELEGATE_H_
6 #define ANDROID_WEBVIEW_BROWSER_AW_SSL_HOST_STATE_DELEGATE_H_
7
8 #include <map>
9 #include <set>
10 #include <string>
11
12 #include "content/public/browser/ssl_host_state_delegate.h"
13 #include "net/base/hash_value.h"
14 #include "net/cert/cert_status_flags.h"
15 #include "net/cert/x509_certificate.h"
16
17 namespace android_webview {
18 namespace {
19 // This class is useful for maintaining policies about which certificates are
20 // permitted for a particular purpose.
21 class CertPolicy {
22 public:
23 CertPolicy();
24 ~CertPolicy();
25 // Returns true if the user has decided to proceed through the ssl error
26 // before. For a certificate to be allowed, it must not have any
27 // *additional* errors from when it was allowed.
28 bool Check(const net::X509Certificate& cert, net::CertStatus error) const;
29
30 // Causes the policy to allow this certificate for a given |error|. And
31 // remember the user's choice.
32 void Allow(const net::X509Certificate& cert, net::CertStatus error);
33
34 private:
35 // The set of fingerprints of allowed certificates.
36 std::map<net::SHA1HashValue, net::CertStatus, net::SHA1HashValueLessThan>
jww 2014/12/12 01:48:41 As a rule, we should never use SHA1 hashes for sec
hush (inactive) 2014/12/12 02:42:37 Done.
37 allowed_;
38 };
39 }
40
41 class AwSSLHostStateDelegate : public content::SSLHostStateDelegate {
42 public:
43 AwSSLHostStateDelegate();
44 virtual ~AwSSLHostStateDelegate();
45
46 // Records that |cert| is permitted to be used for |host| in the future, for
47 // a specified |error| type.
48 void AllowCert(const std::string& host,
49 const net::X509Certificate& cert,
50 net::CertStatus error) override;
51
52 void Clear() override;
53
54 // Queries whether |cert| is allowed or denied for |host| and |error|.
55 content::SSLHostStateDelegate::CertJudgment QueryPolicy(
56 const std::string& host,
57 const net::X509Certificate& cert,
58 net::CertStatus error,
59 bool* expired_previous_decision) override;
60
61 // Records that a host has run insecure content.
62 void HostRanInsecureContent(const std::string& host, int pid) override;
63
64 // Returns whether the specified host ran insecure content.
65 bool DidHostRunInsecureContent(const std::string& host,
66 int pid) const override;
67
68 private:
69 // A BrokenHostEntry is a pair of (host, process_id) that indicates the host
70 // contains insecure content in that renderer process.
71 typedef std::pair<std::string, int> BrokenHostEntry;
72
73 // Hosts which have been contaminated with insecure content in the
74 // specified process. Note that insecure content can travel between
75 // same-origin frames in one processs but cannot jump between processes.
76 std::set<BrokenHostEntry> ran_insecure_content_hosts_;
77
78 // Certificate policies for each host.
79 std::map<std::string, CertPolicy> cert_policy_for_host_;
80
81 DISALLOW_COPY_AND_ASSIGN(AwSSLHostStateDelegate);
82 };
83
84 } // namespace android_webview
85
86 #endif // ANDROID_WEBVIEW_BROWSER_AW_SSL_HOST_STATE_DELEGATE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698