OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "net/base/cert_test_util.h" | 5 #include "net/base/cert_test_util.h" |
6 | 6 |
7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
8 | 8 |
9 #if defined(USE_OPENSSL) | 9 #if defined(USE_OPENSSL) |
10 #include <openssl/err.h> | 10 #include <openssl/err.h> |
(...skipping 14 matching lines...) Expand all Loading... |
25 #include "net/base/x509_certificate.h" | 25 #include "net/base/x509_certificate.h" |
26 | 26 |
27 namespace net { | 27 namespace net { |
28 | 28 |
29 #if defined(USE_OPENSSL) | 29 #if defined(USE_OPENSSL) |
30 X509Certificate* AddTemporaryRootCertToStore(X509* x509_cert) { | 30 X509Certificate* AddTemporaryRootCertToStore(X509* x509_cert) { |
31 if (!X509_STORE_add_cert(X509Certificate::cert_store(), x509_cert)) { | 31 if (!X509_STORE_add_cert(X509Certificate::cert_store(), x509_cert)) { |
32 unsigned long error_code = ERR_get_error(); | 32 unsigned long error_code = ERR_get_error(); |
33 if (ERR_GET_LIB(error_code) != ERR_LIB_X509 || | 33 if (ERR_GET_LIB(error_code) != ERR_LIB_X509 || |
34 ERR_GET_REASON(error_code) != X509_R_CERT_ALREADY_IN_HASH_TABLE) { | 34 ERR_GET_REASON(error_code) != X509_R_CERT_ALREADY_IN_HASH_TABLE) { |
35 base::ClearOpenSSLERRStack(); | 35 base::ClearOpenSSLERRStack(FROM_HERE); |
36 return NULL; | 36 return NULL; |
37 } | 37 } |
38 } | 38 } |
39 return X509Certificate::CreateFromHandle( | 39 return X509Certificate::CreateFromHandle( |
40 x509_cert, X509Certificate::SOURCE_LONE_CERT_IMPORT, | 40 x509_cert, X509Certificate::SOURCE_LONE_CERT_IMPORT, |
41 X509Certificate::OSCertHandles()); | 41 X509Certificate::OSCertHandles()); |
42 } | 42 } |
43 | 43 |
44 X509Certificate* LoadTemporaryRootCert(const FilePath& filename) { | 44 X509Certificate* LoadTemporaryRootCert(const FilePath& filename) { |
45 base::EnsureOpenSSLInit(); | 45 base::EnsureOpenSSLInit(); |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 SecCertificateRef cert_ref = static_cast<SecCertificateRef>( | 147 SecCertificateRef cert_ref = static_cast<SecCertificateRef>( |
148 const_cast<void*>(CFArrayGetValueAtIndex(cert_array, 0))); | 148 const_cast<void*>(CFArrayGetValueAtIndex(cert_array, 0))); |
149 | 149 |
150 return X509Certificate::CreateFromHandle(cert_ref, | 150 return X509Certificate::CreateFromHandle(cert_ref, |
151 X509Certificate::SOURCE_LONE_CERT_IMPORT, | 151 X509Certificate::SOURCE_LONE_CERT_IMPORT, |
152 X509Certificate::OSCertHandles()); | 152 X509Certificate::OSCertHandles()); |
153 } | 153 } |
154 #endif | 154 #endif |
155 | 155 |
156 } // namespace net | 156 } // namespace net |
OLD | NEW |