blob: e01d5c95dadc9f5e6879158c060ad346e83e41ac (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
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/base/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/base/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
|