| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/ui/android/page_info/certificate_chain_helper.h" | 5 #include "chrome/browser/ui/android/page_info/certificate_chain_helper.h" |
| 6 | 6 |
| 7 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
| 8 #include "base/android/jni_array.h" | 8 #include "base/android/jni_array.h" |
| 9 #include "base/android/jni_string.h" | 9 #include "base/android/jni_string.h" |
| 10 #include "content/public/browser/browser_context.h" | 10 #include "content/public/browser/browser_context.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 | 35 |
| 36 std::vector<std::string> cert_chain; | 36 std::vector<std::string> cert_chain; |
| 37 net::X509Certificate::OSCertHandles cert_handles = | 37 net::X509Certificate::OSCertHandles cert_handles = |
| 38 cert->GetIntermediateCertificates(); | 38 cert->GetIntermediateCertificates(); |
| 39 // Make sure the peer's own cert is the first in the chain, if it's not | 39 // Make sure the peer's own cert is the first in the chain, if it's not |
| 40 // already there. | 40 // already there. |
| 41 if (cert_handles.empty() || cert_handles[0] != cert->os_cert_handle()) | 41 if (cert_handles.empty() || cert_handles[0] != cert->os_cert_handle()) |
| 42 cert_handles.insert(cert_handles.begin(), cert->os_cert_handle()); | 42 cert_handles.insert(cert_handles.begin(), cert->os_cert_handle()); |
| 43 | 43 |
| 44 cert_chain.reserve(cert_handles.size()); | 44 cert_chain.reserve(cert_handles.size()); |
| 45 for (const auto& handle : cert_handles) { | 45 for (auto* handle : cert_handles) { |
| 46 std::string cert_bytes; | 46 std::string cert_bytes; |
| 47 net::X509Certificate::GetDEREncoded(handle, &cert_bytes); | 47 net::X509Certificate::GetDEREncoded(handle, &cert_bytes); |
| 48 cert_chain.push_back(cert_bytes); | 48 cert_chain.push_back(cert_bytes); |
| 49 } | 49 } |
| 50 | 50 |
| 51 return base::android::ToJavaArrayOfByteArray(env, cert_chain); | 51 return base::android::ToJavaArrayOfByteArray(env, cert_chain); |
| 52 } | 52 } |
| 53 | 53 |
| 54 // static | 54 // static |
| 55 bool RegisterCertificateChainHelper(JNIEnv* env) { | 55 bool RegisterCertificateChainHelper(JNIEnv* env) { |
| 56 return RegisterNativesImpl(env); | 56 return RegisterNativesImpl(env); |
| 57 } | 57 } |
| OLD | NEW |