Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(120)

Unified Diff: net/base/temporary_root_certs_openssl.cc

Issue 4646001: Implement LoadTemporaryRoot for Windows (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/net/base
Patch Set: Feedback from phajdan.jr and bulach Created 10 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: net/base/temporary_root_certs_openssl.cc
diff --git a/net/base/temporary_root_certs_openssl.cc b/net/base/temporary_root_certs_openssl.cc
new file mode 100644
index 0000000000000000000000000000000000000000..3f91a01fc026e5e0f94dff99fcf54c7f660700da
--- /dev/null
+++ b/net/base/temporary_root_certs_openssl.cc
@@ -0,0 +1,47 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "net/base/temporary_root_certs.h"
+
+#include <openssl/err.h>
+#include <openssl/x509v3.h>
+
+#include "base/logging.h"
+#include "net/base/openssl_util.h"
+#include "net/base/x509_certificate.h"
+
+namespace net {
+
+bool TemporaryRootCerts::Add(X509Certificate* certificate) {
+ OpenSSLInitSingleton* openssl_init = GetOpenSSLInitSingleton();
+
+ 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(
+ certificate->os_cert_handle())) {
+ unsigned long error_code = ERR_get_error();
+ if (ERR_GET_LIB(error_code) != ERR_LIB_X509 ||
+ ERR_GET_REASON(error_code) != X509_R_CERT_ALREADY_IN_HASH_TABLE) {
+ do {
+ LOG(ERROR) << "X509_STORE_add_cert error: " << error_code;
+ } while ((error_code = ERR_get_error()) != 0);
+ return false;
+ }
+ }
+
+ return true;
+}
+
+void TemporaryRootCerts::Remove(X509Certificate* certificate) {
+ // TODO(rsleevi): With OpenSSL, there is no good public means to
+ // remove a certificate from an X509_STORE. Either we implement a custom
+ // X509_LOOKUP_METHOD, which means implementing a whole host of search
+ // options, or we go directly against the X509_STORE.objs member iterate
+ // through for the desired object, and then sk_X509_OBJECT_delete[_ptr].
+ // 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
+}
+
+TemporaryRootCerts::TemporaryRootCerts() {}
+
+TemporaryRootCerts::~TemporaryRootCerts() {}
+
+} // namespace net

Powered by Google App Engine
This is Rietveld 408576698