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

Unified Diff: net/http/http_util.cc

Issue 425803014: Refactor pooling logic into a helper method (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Working Created 6 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: net/http/http_util.cc
diff --git a/net/http/http_util.cc b/net/http/http_util.cc
index f4f994af6052f294bb52e1714cf1ca625af1cadc..54b66ffe61c9f07198b084b6543950c4acfa46b6 100644
--- a/net/http/http_util.cc
+++ b/net/http/http_util.cc
@@ -1,3 +1,4 @@
+
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -17,7 +18,11 @@
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/time/time.h"
-
+#include "net/cert/cert_verify_result.h"
+#include "net/cert/x509_certificate.h"
+#include "net/http/transport_security_state.h"
+#include "net/ssl/channel_id_service.h"
+#include "net/ssl/ssl_info.h"
namespace net {
@@ -740,6 +745,42 @@ int HttpUtil::MapStatusCodeForHistogram(int code) {
return 0;
}
+// static
+bool HttpUtil::CanPool(TransportSecurityState* transport_security_state,
+ const SSLInfo& ssl_info,
+ const std::string& old_hostname,
+ const std::string& new_hostname) {
+ // Pooling is prohibited if the server cert is not valid for the new domain,
+ // and for connections on which client certs were sent. It is also prohibited
+ // when channel ID was sent if the hosts are from different eTLDs+1.
+ bool unused = false;
+ if (!ssl_info.cert->VerifyNameMatch(new_hostname, &unused))
+ return false;
Ryan Sleevi 2014/08/07 18:49:29 You should check this on 771
Ryan Hamilton 2014/08/08 19:27:43 Done. (But how come?)
Ryan Sleevi 2014/08/11 19:03:43 Forgot to answer this - verify the cert is trusted
Ryan Hamilton 2014/08/12 14:39:06 Oh! Good point.
+
+ if (IsCertStatusError(ssl_info.cert_status))
+ return false;
+
+ if (ssl_info.client_cert_sent)
+ return false;
+
+ if (ssl_info.channel_id_sent &&
+ ChannelIDService::GetDomainForHost(new_hostname) !=
+ ChannelIDService::GetDomainForHost(old_hostname)) {
+ return false;
+ }
+
+ if (!transport_security_state->VerifyPinning(
+ ssl_info.public_key_hashes,
+ ssl_info.is_issued_by_known_root,
+ /* sni_available= */ true,
+ new_hostname,
+ /* pinning_failure_log= */ NULL)) {
Ryan Sleevi 2014/08/07 18:49:29 1) git-cl-format this (you should be four *additio
Ryan Hamilton 2014/08/08 19:27:43 Done.
+ return false;
+ }
+
+ return true;
+}
+
// BNF from section 4.2 of RFC 2616:
//
// message-header = field-name ":" [ field-value ]

Powered by Google App Engine
This is Rietveld 408576698