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

Side by Side Diff: net/cert/test_root_certs_openssl.cc

Issue 992733002: Remove //net (except for Android test stuff) and sdch (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 9 months 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 unified diff | Download patch
« no previous file with comments | « net/cert/test_root_certs_nss.cc ('k') | net/cert/test_root_certs_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2011 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/cert/test_root_certs.h"
6
7 #include <openssl/err.h>
8 #include <openssl/x509v3.h>
9
10 #include "base/location.h"
11 #include "base/logging.h"
12 #include "crypto/openssl_util.h"
13 #include "net/cert/x509_certificate.h"
14
15 namespace net {
16
17 bool TestRootCerts::Add(X509Certificate* certificate) {
18 if (!X509_STORE_add_cert(X509Certificate::cert_store(),
19 certificate->os_cert_handle())) {
20 unsigned long error_code = ERR_peek_error();
21 if (ERR_GET_LIB(error_code) != ERR_LIB_X509 ||
22 ERR_GET_REASON(error_code) != X509_R_CERT_ALREADY_IN_HASH_TABLE) {
23 crypto::ClearOpenSSLERRStack(FROM_HERE);
24 return false;
25 }
26 ERR_clear_error();
27 }
28
29 temporary_roots_.push_back(certificate);
30 return true;
31 }
32
33 void TestRootCerts::Clear() {
34 if (temporary_roots_.empty())
35 return;
36
37 temporary_roots_.clear();
38 X509Certificate::ResetCertStore();
39 }
40
41 bool TestRootCerts::IsEmpty() const {
42 return temporary_roots_.empty();
43 }
44
45 bool TestRootCerts::Contains(X509* cert) const {
46 for (std::vector<scoped_refptr<X509Certificate> >::const_iterator it =
47 temporary_roots_.begin();
48 it != temporary_roots_.end(); ++it) {
49 if (X509Certificate::IsSameOSCert(cert, (*it)->os_cert_handle()))
50 return true;
51 }
52 return false;
53 }
54
55 TestRootCerts::~TestRootCerts() {}
56
57 void TestRootCerts::Init() {}
58
59 } // namespace net
OLDNEW
« no previous file with comments | « net/cert/test_root_certs_nss.cc ('k') | net/cert/test_root_certs_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698