Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "mock_cert_verifier.h" | |
| 6 | |
| 7 #include <string> | |
| 8 #include <vector> | |
| 9 | |
| 10 #include "base/android/jni_android.h" | |
| 11 #include "base/android/jni_array.h" | |
| 12 #include "base/android/scoped_java_ref.h" | |
| 13 #include "jni/MockCertVerifier_jni.h" | |
| 14 #include "net/base/net_errors.h" | |
| 15 #include "net/base/test_data_directory.h" | |
| 16 #include "net/cert/cert_verifier.h" | |
| 17 #include "net/cert/cert_verify_result.h" | |
| 18 #include "net/cert/mock_cert_verifier.h" | |
| 19 #include "net/test/cert_test_util.h" | |
| 20 | |
| 21 namespace cronet { | |
| 22 | |
| 23 static jlong CreateMockCertVerifier(JNIEnv* env, | |
| 24 const JavaParamRef<jclass>& jcaller, | |
| 25 const JavaParamRef<jobjectArray>& jcerts) { | |
| 26 std::vector<std::string> certs; | |
| 27 base::android::AppendJavaStringArrayToStringVector(env, jcerts, &certs); | |
| 28 net::MockCertVerifier* mock_cert_verifier = new net::MockCertVerifier(); | |
| 29 for (auto cert : certs) { | |
| 30 net::CertVerifyResult verify_result; | |
| 31 verify_result.verified_cert = | |
| 32 net::ImportCertFromFile(net::GetTestCertsDirectory(), cert); | |
|
mef
2015/10/12 18:35:03
Do we need to add TestCertsDirectory as resources
xunjieli
2015/10/13 01:58:02
The change in build/android/pylib/instrumentation/
| |
| 33 mock_cert_verifier->AddResultForCert(verify_result.verified_cert.get(), | |
| 34 verify_result, net::OK); | |
| 35 } | |
| 36 | |
| 37 return reinterpret_cast<jlong>(mock_cert_verifier); | |
| 38 } | |
| 39 | |
| 40 static void DestroyMockCertVerifier(JNIEnv* env, | |
| 41 const JavaParamRef<jclass>& jcaller, | |
| 42 jlong jmock_verifier) { | |
| 43 net::MockCertVerifier* mock_cert_verifier = | |
| 44 reinterpret_cast<net::MockCertVerifier*>(jmock_verifier); | |
| 45 delete mock_cert_verifier; | |
| 46 } | |
| 47 | |
| 48 bool RegisterMockCertVerifier(JNIEnv* env) { | |
| 49 return RegisterNativesImpl(env); | |
| 50 } | |
| 51 | |
| 52 } // namespace cronet | |
| OLD | NEW |