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

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: Small javadoc fix Created 5 years, 2 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: 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..2134fd54b9aaf8ae52aeb67254efdc951aae0237 100644
--- a/components/cronet/android/cronet_url_request_context_adapter.cc
+++ b/components/cronet/android/cronet_url_request_context_adapter.cc
@@ -372,6 +372,32 @@ void CronetURLRequestContextAdapter::InitializeOnNetworkThread(
}
}
+ // Iterate through HPKP configuration for every host
mef 2015/11/02 17:56:56 nit: I believe (although I can't find proof ATM) t
kapishnikov 2015/11/02 22:45:49 Done.
+ 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 (auto hash_itr = hpkp.pin_hashes.begin();
+ hash_itr != hpkp.pin_hashes.end(); ++hash_itr) {
+ const std::string& pin_hash = **hash_itr;
mef 2015/11/02 17:56:56 I think you can just inline this.
kapishnikov 2015/11/02 22:45:49 Done.
+ auto hashValue = net::HashValue(net::HASH_VALUE_SHA256);
mef 2015/11/02 17:56:56 no camelCase for local variables.
kapishnikov 2015/11/02 22:45:49 Done.
+ bool good_hash = hashValue.FromString(pin_hash);
+ if (good_hash) {
+ hash_value_vector.push_back(hashValue);
+ } else {
+ LOG(WARNING) << "Unable to add hash value " << pin_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