| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 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/extensions/api/platform_keys/verify_trust_api.h" | 5 #include "chrome/browser/extensions/api/platform_keys/verify_trust_api.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/memory/linked_ptr.h" | 11 #include "base/memory/linked_ptr.h" |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/stl_util.h" | |
| 14 #include "chrome/browser/extensions/api/platform_keys/platform_keys_api.h" | 13 #include "chrome/browser/extensions/api/platform_keys/platform_keys_api.h" |
| 15 #include "chrome/common/extensions/api/platform_keys_internal.h" | 14 #include "chrome/common/extensions/api/platform_keys_internal.h" |
| 16 #include "extensions/browser/extension_registry_factory.h" | 15 #include "extensions/browser/extension_registry_factory.h" |
| 17 #include "net/base/net_errors.h" | 16 #include "net/base/net_errors.h" |
| 18 #include "net/cert/cert_verifier.h" | 17 #include "net/cert/cert_verifier.h" |
| 19 #include "net/cert/cert_verify_result.h" | 18 #include "net/cert/cert_verify_result.h" |
| 20 #include "net/cert/x509_certificate.h" | 19 #include "net/cert/x509_certificate.h" |
| 21 #include "net/log/net_log.h" | 20 #include "net/log/net_log.h" |
| 22 #include "net/ssl/ssl_config_service.h" | 21 #include "net/ssl/ssl_config_service.h" |
| 23 | 22 |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 return; | 160 return; |
| 162 } | 161 } |
| 163 | 162 |
| 164 std::vector<base::StringPiece> der_cert_chain; | 163 std::vector<base::StringPiece> der_cert_chain; |
| 165 for (const std::vector<char>& cert_der : details.server_certificate_chain) { | 164 for (const std::vector<char>& cert_der : details.server_certificate_chain) { |
| 166 if (cert_der.empty()) { | 165 if (cert_der.empty()) { |
| 167 callback.Run(platform_keys::kErrorInvalidX509Cert, 0, 0); | 166 callback.Run(platform_keys::kErrorInvalidX509Cert, 0, 0); |
| 168 return; | 167 return; |
| 169 } | 168 } |
| 170 der_cert_chain.push_back(base::StringPiece( | 169 der_cert_chain.push_back(base::StringPiece( |
| 171 reinterpret_cast<const char*>(vector_as_array(&cert_der)), | 170 reinterpret_cast<const char*>(cert_der.data()), cert_der.size())); |
| 172 cert_der.size())); | |
| 173 } | 171 } |
| 174 scoped_refptr<net::X509Certificate> cert_chain( | 172 scoped_refptr<net::X509Certificate> cert_chain( |
| 175 net::X509Certificate::CreateFromDERCertChain(der_cert_chain)); | 173 net::X509Certificate::CreateFromDERCertChain(der_cert_chain)); |
| 176 if (!cert_chain) { | 174 if (!cert_chain) { |
| 177 callback.Run(platform_keys::kErrorInvalidX509Cert, 0, 0); | 175 callback.Run(platform_keys::kErrorInvalidX509Cert, 0, 0); |
| 178 return; | 176 return; |
| 179 } | 177 } |
| 180 | 178 |
| 181 if (!ContainsKey(extension_to_verifier_, extension_id)) { | 179 if (!ContainsKey(extension_to_verifier_, extension_id)) { |
| 182 extension_to_verifier_[extension_id] = | 180 extension_to_verifier_[extension_id] = |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 scoped_ptr<net::CertVerifyResult> verify_result, | 215 scoped_ptr<net::CertVerifyResult> verify_result, |
| 218 RequestState* request_state, | 216 RequestState* request_state, |
| 219 int return_value) { | 217 int return_value) { |
| 220 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); | 218 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); |
| 221 | 219 |
| 222 callback.Run(std::string() /* no error message */, return_value, | 220 callback.Run(std::string() /* no error message */, return_value, |
| 223 verify_result->cert_status); | 221 verify_result->cert_status); |
| 224 } | 222 } |
| 225 | 223 |
| 226 } // namespace extensions | 224 } // namespace extensions |
| OLD | NEW |