Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "net/base/temporary_root_certs.h" | |
| 6 | |
| 7 #include <openssl/err.h> | |
| 8 #include <openssl/x509v3.h> | |
| 9 | |
| 10 #include "base/logging.h" | |
| 11 #include "net/base/openssl_util.h" | |
| 12 #include "net/base/x509_certificate.h" | |
| 13 | |
| 14 namespace net { | |
| 15 | |
| 16 bool TemporaryRootCerts::Add(X509Certificate* certificate) { | |
| 17 OpenSSLInitSingleton* openssl_init = GetOpenSSLInitSingleton(); | |
| 18 | |
| 19 if (!X509_STORE_add_cert(openssl_init->x509_store(), | |
|
joth
2010/11/17 10:37:02
note this will now need to be
X509_STORE_add_cert(
| |
| 20 certificate->os_cert_handle())) { | |
| 21 unsigned long error_code = ERR_get_error(); | |
| 22 if (ERR_GET_LIB(error_code) != ERR_LIB_X509 || | |
| 23 ERR_GET_REASON(error_code) != X509_R_CERT_ALREADY_IN_HASH_TABLE) { | |
| 24 do { | |
| 25 LOG(ERROR) << "X509_STORE_add_cert error: " << error_code; | |
| 26 } while ((error_code = ERR_get_error()) != 0); | |
| 27 return false; | |
| 28 } | |
| 29 } | |
| 30 | |
| 31 return true; | |
| 32 } | |
| 33 | |
| 34 void TemporaryRootCerts::Remove(X509Certificate* certificate) { | |
| 35 // TODO(rsleevi): With OpenSSL, there is no good public means to | |
| 36 // remove a certificate from an X509_STORE. Either we implement a custom | |
| 37 // X509_LOOKUP_METHOD, which means implementing a whole host of search | |
| 38 // options, or we go directly against the X509_STORE.objs member iterate | |
| 39 // through for the desired object, and then sk_X509_OBJECT_delete[_ptr]. | |
| 40 // Either way seems messy for something intended as a temporary test utility. | |
|
bulach
2010/11/09 16:21:09
maybe:
LOG(WARNING) << "OpenSSL doesn't support re
joth
2010/11/17 10:37:02
Would it help if we added something of a 'test mod
| |
| 41 } | |
| 42 | |
| 43 TemporaryRootCerts::TemporaryRootCerts() {} | |
| 44 | |
| 45 TemporaryRootCerts::~TemporaryRootCerts() {} | |
| 46 | |
| 47 } // namespace net | |
| OLD | NEW |