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

Side by Side Diff: net/base/test_root_certs_android.cc

Issue 11316210: Implement TestRootCerts for Android (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: address Ryan's remarks Created 8 years 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/android/network_library.cc ('k') | net/net.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/base/test_root_certs.h" 5 #include "net/base/test_root_certs.h"
6 6
7 #include <openssl/err.h>
8 #include <openssl/x509v3.h>
9
10 #include "base/location.h" 7 #include "base/location.h"
11 #include "base/logging.h" 8 #include "base/logging.h"
12 #include "crypto/openssl_util.h" 9 #include "net/android/network_library.h"
13 #include "net/base/x509_certificate.h" 10 #include "net/base/x509_certificate.h"
14 11
15 namespace net { 12 namespace net {
16 13
17 bool TestRootCerts::Add(X509Certificate* certificate) { 14 bool TestRootCerts::Add(X509Certificate* certificate) {
18 if (!X509_STORE_add_cert(X509Certificate::cert_store(), 15 std::string cert_bytes;
19 certificate->os_cert_handle())) { 16 if (!X509Certificate::GetDEREncoded(certificate->os_cert_handle(),
20 unsigned long error_code = ERR_peek_error(); 17 &cert_bytes))
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; 18 return false;
25 } 19 android::AddTestRootCertificate(
26 ERR_clear_error(); 20 reinterpret_cast<const uint8*>(cert_bytes.data()), cert_bytes.size());
27 }
28
29 empty_ = false;
30 return true; 21 return true;
31 } 22 }
32 23
33 void TestRootCerts::Clear() { 24 void TestRootCerts::Clear() {
34 if (empty_) 25 if (empty_)
35 return; 26 return;
36 27
37 X509Certificate::ResetCertStore(); 28 android::ClearTestRootCertificates();
38 empty_ = true; 29 empty_ = true;
39 } 30 }
40 31
41 bool TestRootCerts::IsEmpty() const { 32 bool TestRootCerts::IsEmpty() const {
42 return empty_; 33 return empty_;
43 } 34 }
44 35
45 TestRootCerts::~TestRootCerts() {} 36 TestRootCerts::~TestRootCerts() {}
46 37
47 void TestRootCerts::Init() { 38 void TestRootCerts::Init() {
48 empty_ = true; 39 empty_ = true;
49 } 40 }
50 41
51 } // namespace net 42 } // namespace net
OLDNEW
« no previous file with comments | « net/android/network_library.cc ('k') | net/net.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698