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( |