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

Unified Diff: components/cronet/android/cronet_url_request_context_adapter.cc

Issue 1407263010: [Cronet] Public key pinning for Java API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Refactored X509UtilTest to avoid code duplication Created 5 years, 1 month 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: components/cronet/android/cronet_url_request_context_adapter.cc
diff --git a/components/cronet/android/cronet_url_request_context_adapter.cc b/components/cronet/android/cronet_url_request_context_adapter.cc
index 37a18cefb5069d6d39141a0d0273914781c85816..7f3b4c8f4c120ef460fa2d9dfc6e89309a8b5245 100644
--- a/components/cronet/android/cronet_url_request_context_adapter.cc
+++ b/components/cronet/android/cronet_url_request_context_adapter.cc
@@ -372,6 +372,30 @@ void CronetURLRequestContextAdapter::InitializeOnNetworkThread(
}
}
+ // Iterate through HPKP configuration for every host.
+ for (auto hpkp_itr = config->hpkp_list.begin();
+ hpkp_itr != config->hpkp_list.end(); ++hpkp_itr) {
+ const URLRequestContextConfig::Hpkp& hpkp = **hpkp_itr;
+
+ // Convert the vector of hash strings from the config to
+ // a vector of HashValue objects.
+ net::HashValueVector hash_value_vector;
+ for (const auto& hash : hpkp.pin_hashes) {
+ auto hash_value = net::HashValue(net::HASH_VALUE_SHA256);
+ bool good_hash = hash_value.FromString(*hash);
+ if (good_hash) {
+ hash_value_vector.push_back(hash_value);
+ } else {
+ LOG(WARNING) << "Unable to add hash value " << *hash;
+ }
+ }
+
+ // Add the host pinning.
+ context_->transport_security_state()->AddHPKP(hpkp.host, base::Time::Max(),
+ hpkp.include_subdomains,
+ hash_value_vector, GURL());
+ }
+
JNIEnv* env = base::android::AttachCurrentThread();
jcronet_url_request_context_.Reset(env, jcronet_url_request_context.obj());
Java_CronetUrlRequestContext_initNetworkThread(

Powered by Google App Engine
This is Rietveld 408576698