Commit ef69f053 authored by palmer@chromium.org's avatar palmer@chromium.org

Clean up comments and code for pin validation.

It should be crystal clear when, and why, pin validation is and is not
performed.

TEST=net_unittests; with an OFFICIAL_BUILD: can still connect to pinned
sites, and https://pinningtest.appspot.com fails with
net::ERR_SSL_PINNED_KEY_NOT_IN_CERT_CHAIN.


Review URL: https://chromiumcodereview.appspot.com/13466020

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@192654 0039d316-1c4b-4281-b951-d872f2087c98
parent 11ff1c61
...@@ -3432,15 +3432,26 @@ int SSLClientSocketNSS::DoVerifyCertComplete(int result) { ...@@ -3432,15 +3432,26 @@ int SSLClientSocketNSS::DoVerifyCertComplete(int result) {
// Pinning is only enabled for official builds to make sure that others don't // Pinning is only enabled for official builds to make sure that others don't
// end up with pins that cannot be easily updated. // end up with pins that cannot be easily updated.
// //
// TODO(agl): we might have an issue here where a request for foo.example.com // 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 // merges into a SPDY connection to www.example.com, and gets a different
// certificate. // 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).
//
const CertStatus cert_status = server_cert_verify_result_.cert_status; const CertStatus cert_status = server_cert_verify_result_.cert_status;
if ((result == OK || (IsCertificateError(result) && if (transport_security_state_ &&
IsCertStatusMinorError(cert_status))) && (result == OK ||
(IsCertificateError(result) && IsCertStatusMinorError(cert_status))) &&
server_cert_verify_result_.is_issued_by_known_root && server_cert_verify_result_.is_issued_by_known_root &&
transport_security_state_) { TransportSecurityState::IsBuildTimely()) {
bool sni_available = bool sni_available =
ssl_config_.version_max >= SSL_PROTOCOL_VERSION_TLS1 || ssl_config_.version_max >= SSL_PROTOCOL_VERSION_TLS1 ||
ssl_config_.version_fallback; ssl_config_.version_fallback;
...@@ -3451,13 +3462,10 @@ int SSLClientSocketNSS::DoVerifyCertComplete(int result) { ...@@ -3451,13 +3462,10 @@ int SSLClientSocketNSS::DoVerifyCertComplete(int result) {
&domain_state) && &domain_state) &&
domain_state.HasPublicKeyPins()) { domain_state.HasPublicKeyPins()) {
if (!domain_state.CheckPublicKeyPins( if (!domain_state.CheckPublicKeyPins(
server_cert_verify_result_.public_key_hashes)) { server_cert_verify_result_.public_key_hashes)) {
// Pins are not enforced if the build is too old. result = ERR_SSL_PINNED_KEY_NOT_IN_CERT_CHAIN;
if (TransportSecurityState::IsBuildTimely()) { UMA_HISTOGRAM_BOOLEAN("Net.PublicKeyPinSuccess", false);
result = ERR_SSL_PINNED_KEY_NOT_IN_CERT_CHAIN; TransportSecurityState::ReportUMAOnPinFailure(host);
UMA_HISTOGRAM_BOOLEAN("Net.PublicKeyPinSuccess", false);
TransportSecurityState::ReportUMAOnPinFailure(host);
}
} else { } else {
UMA_HISTOGRAM_BOOLEAN("Net.PublicKeyPinSuccess", true); UMA_HISTOGRAM_BOOLEAN("Net.PublicKeyPinSuccess", true);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment