Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2014 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 "android_webview/browser/aw_ssl_host_state_delegate.h" | |
| 6 | |
| 7 #include "net/base/hash_value.h" | |
| 8 | |
| 9 using content::SSLHostStateDelegate; | |
| 10 | |
| 11 namespace android_webview { | |
| 12 namespace internal { | |
|
sgurun-gerrit only
2014/12/12 04:23:09
nit: add a line between namespaces
hush (inactive)
2014/12/12 19:43:39
Done.
| |
| 13 net::SHA256HashValue getChainFingerprint256(const net::X509Certificate& cert) { | |
| 14 net::SHA256HashValue fingerprint = | |
| 15 net::X509Certificate::CalculateChainFingerprint256( | |
| 16 cert.os_cert_handle(), cert.GetIntermediateCertificates()); | |
| 17 return fingerprint; | |
| 18 } | |
| 19 | |
| 20 CertPolicy::CertPolicy() { | |
| 21 } | |
| 22 CertPolicy::~CertPolicy() { | |
| 23 } | |
| 24 | |
| 25 // For an allowance, we consider a given |cert| to be a match to a saved | |
| 26 // allowed cert if the |error| is an exact match to or subset of the errors | |
| 27 // in the saved CertStatus. | |
| 28 bool CertPolicy::Check(const net::X509Certificate& cert, | |
| 29 net::CertStatus error) const { | |
| 30 net::SHA256HashValue fingerprint = getChainFingerprint256(cert); | |
| 31 std::map<net::SHA256HashValue, net::CertStatus, | |
| 32 net::SHA256HashValueLessThan>::const_iterator allowed_iter = | |
| 33 allowed_.find(fingerprint); | |
| 34 if ((allowed_iter != allowed_.end()) && (allowed_iter->second & error) && | |
| 35 !(~(allowed_iter->second & error) ^ ~error)) { | |
|
hush (inactive)
2014/12/12 19:43:39
I copied this if statement from m37 code, and I th
| |
| 36 return true; | |
| 37 } | |
| 38 | |
|
sgurun-gerrit only
2014/12/12 04:23:09
nit: remove the empty line
hush (inactive)
2014/12/12 19:43:39
Done.
| |
| 39 return false; | |
| 40 } | |
| 41 | |
| 42 void CertPolicy::Allow(const net::X509Certificate& cert, | |
| 43 net::CertStatus error) { | |
| 44 // If this same cert had already been saved with a different error status, | |
| 45 // this will replace it with the new error status. | |
| 46 net::SHA256HashValue fingerprint = getChainFingerprint256(cert); | |
| 47 | |
|
sgurun-gerrit only
2014/12/12 04:23:09
nit: remove the empty line
hush (inactive)
2014/12/12 19:43:39
Done.
| |
| 48 allowed_[fingerprint] = error; | |
| 49 } | |
| 50 } // namespace internal | |
| 51 | |
| 52 AwSSLHostStateDelegate::AwSSLHostStateDelegate() { | |
| 53 } | |
| 54 | |
| 55 AwSSLHostStateDelegate::~AwSSLHostStateDelegate() { | |
| 56 } | |
| 57 | |
| 58 void AwSSLHostStateDelegate::HostRanInsecureContent(const std::string& host, | |
| 59 int pid) { | |
| 60 ran_insecure_content_hosts_.insert(BrokenHostEntry(host, pid)); | |
| 61 } | |
| 62 | |
| 63 bool AwSSLHostStateDelegate::DidHostRunInsecureContent(const std::string& host, | |
| 64 int pid) const { | |
| 65 return !!ran_insecure_content_hosts_.count(BrokenHostEntry(host, pid)); | |
|
sgurun-gerrit only
2014/12/12 04:23:09
We are changing behavior here compared to returni
hush (inactive)
2014/12/12 19:43:39
Yes. I did some investigations too. This method is
jww
2014/12/12 20:02:50
I'm surprised there's no way to extract this infor
| |
| 66 } | |
| 67 | |
| 68 void AwSSLHostStateDelegate::AllowCert(const std::string& host, | |
| 69 const net::X509Certificate& cert, | |
| 70 net::CertStatus error) { | |
| 71 cert_policy_for_host_[host].Allow(cert, error); | |
| 72 } | |
| 73 | |
| 74 void AwSSLHostStateDelegate::Clear() { | |
| 75 cert_policy_for_host_.clear(); | |
| 76 } | |
| 77 | |
| 78 SSLHostStateDelegate::CertJudgment AwSSLHostStateDelegate::QueryPolicy( | |
| 79 const std::string& host, | |
| 80 const net::X509Certificate& cert, | |
| 81 net::CertStatus error, | |
| 82 bool* expired_previous_decision) { | |
| 83 return cert_policy_for_host_[host].Check(cert, error) | |
| 84 ? SSLHostStateDelegate::ALLOWED | |
| 85 : SSLHostStateDelegate::DENIED; | |
| 86 } | |
| 87 | |
| 88 } // namespace android_webview | |
| OLD | NEW |