diff options
author | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-29 21:48:11 +0000 |
---|---|---|
committer | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-29 21:48:11 +0000 |
commit | 6e7845aed4759ab35d722ce0551b5a90d21e7640 (patch) | |
tree | f29a3f007f7ded842d2096446ff7ecaf186cb362 /net/cert/test_root_certs_openssl.cc | |
parent | a6b4f91d970aa2b71b0f3552dbc11e94f7650fd5 (diff) | |
download | chromium_src-6e7845aed4759ab35d722ce0551b5a90d21e7640.zip chromium_src-6e7845aed4759ab35d722ce0551b5a90d21e7640.tar.gz chromium_src-6e7845aed4759ab35d722ce0551b5a90d21e7640.tar.bz2 |
net: extract net/cert out of net/base
This introduces the following dependency of net/base on things outside:
net/base/openssl_client_key_store.cc:#include "net/cert/x509_certificate.h"
BUG=70818
Review URL: https://codereview.chromium.org/13006020
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@191450 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/cert/test_root_certs_openssl.cc')
-rw-r--r-- | net/cert/test_root_certs_openssl.cc | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/net/cert/test_root_certs_openssl.cc b/net/cert/test_root_certs_openssl.cc new file mode 100644 index 0000000..3d5cf3d --- /dev/null +++ b/net/cert/test_root_certs_openssl.cc @@ -0,0 +1,51 @@ +// Copyright (c) 2011 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/cert/test_root_certs.h" + +#include <openssl/err.h> +#include <openssl/x509v3.h> + +#include "base/location.h" +#include "base/logging.h" +#include "crypto/openssl_util.h" +#include "net/cert/x509_certificate.h" + +namespace net { + +bool TestRootCerts::Add(X509Certificate* certificate) { + if (!X509_STORE_add_cert(X509Certificate::cert_store(), + certificate->os_cert_handle())) { + unsigned long error_code = ERR_peek_error(); + if (ERR_GET_LIB(error_code) != ERR_LIB_X509 || + ERR_GET_REASON(error_code) != X509_R_CERT_ALREADY_IN_HASH_TABLE) { + crypto::ClearOpenSSLERRStack(FROM_HERE); + return false; + } + ERR_clear_error(); + } + + empty_ = false; + return true; +} + +void TestRootCerts::Clear() { + if (empty_) + return; + + X509Certificate::ResetCertStore(); + empty_ = true; +} + +bool TestRootCerts::IsEmpty() const { + return empty_; +} + +TestRootCerts::~TestRootCerts() {} + +void TestRootCerts::Init() { + empty_ = true; +} + +} // namespace net |