Index: net/http/transport_security_state.cc |
diff --git a/net/http/transport_security_state.cc b/net/http/transport_security_state.cc |
index 0b209b356e834dc7018bb0d9a743711b3e02cff5..8a4fda4d2da1c995b3ce1aacb1b30a6db4a1c397 100644 |
--- a/net/http/transport_security_state.cc |
+++ b/net/http/transport_security_state.cc |
@@ -666,6 +666,55 @@ bool TransportSecurityState::AddHPKPHeader(const std::string& host, |
return false; |
} |
+bool TransportSecurityState::VerifyPinning( |
+ const HashValueVector& public_key_hashes, |
+ bool is_issued_by_known_root, |
+ bool sni_available, |
+ const std::string& host, |
+ std::string* pinning_failure_log) { |
+#if defined(OFFICIAL_BUILD) && !defined(OS_ANDROID) && !defined(OS_IOS) |
agl
2014/08/07 18:32:59
Now that this is it's own function, I think this w
Ryan Hamilton
2014/08/07 18:44:26
Done. (Though I used "#else" instead of #endif bec
|
+ // Take care of any mandates for public key pinning. |
+ // |
+ // Pinning is only enabled for official builds to make sure that others don't |
+ // end up with pins that cannot be easily updated. |
+ // |
+ // TODO(agl): We might have an issue here where a request for foo.example.com |
+ // merges into a SPDY connection to www.example.com, and gets a different |
+ // certificate. |
+ |
+ // Perform pin validation if, and only if, all these conditions obtain: |
+ // |
+ // * a TransportSecurityState object is available; |
+ // * the server's certificate chain is valid (or suffers from only a minor |
+ // error); |
+ // * the server's certificate chain chains up to a known root (i.e. not a |
+ // user-installed trust anchor); and |
+ // * the build is recent (very old builds should fail open so that users |
+ // have some chance to recover). |
+ // |
+ if (!is_issued_by_known_root || !TransportSecurityState::IsBuildTimely()) { |
+ return true; |
+ } |
agl
2014/08/07 18:32:59
if (!is_issued_by_known_root ||
!TransportSecu
Ryan Hamilton
2014/08/07 18:44:26
Done.
|
+ |
+ if (!HasPublicKeyPins(host, sni_available)) |
+ return true; |
+ |
+ if (CheckPublicKeyPins(host, |
palmer
2014/08/07 18:50:50
Does it make sense to just move the logic in this
Ryan Hamilton
2014/08/07 20:09:38
Hm. I'm totally happy to do this and it seems like
Ryan Sleevi
2014/08/07 20:40:17
How so / what tests? Our tests don't have OFFICIAL
Ryan Hamilton
2014/08/07 22:07:11
Discussed offline. I *think* I've done what you pr
|
+ sni_available, |
+ public_key_hashes, |
+ pinning_failure_log)) { |
+ UMA_HISTOGRAM_BOOLEAN("Net.PublicKeyPinSuccess", true); |
+ return true; |
+ } |
+ |
+ LOG(ERROR) << *pinning_failure_log; |
+ UMA_HISTOGRAM_BOOLEAN("Net.PublicKeyPinSuccess", false); |
+ TransportSecurityState::ReportUMAOnPinFailure(host); |
+#else |
+ return true; |
+#endif |
+} |
+ |
bool TransportSecurityState::AddHSTS(const std::string& host, |
const base::Time& expiry, |
bool include_subdomains) { |