diff options
author | ppi@chromium.org <ppi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-12 01:31:55 +0000 |
---|---|---|
committer | ppi@chromium.org <ppi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-12 01:31:55 +0000 |
commit | 87ccb9908e00752d2aa07b5971c0b10210f61a9a (patch) | |
tree | 934842c1ae7df745ec5199844296eae91c5e2b25 /net/base | |
parent | 96a59d246092ff9ff5ad9e3a9d0a3f09125e6f78 (diff) | |
download | chromium_src-87ccb9908e00752d2aa07b5971c0b10210f61a9a.zip chromium_src-87ccb9908e00752d2aa07b5971c0b10210f61a9a.tar.gz chromium_src-87ccb9908e00752d2aa07b5971c0b10210f61a9a.tar.bz2 |
Implement TestRootCerts for Android
Currently we are unable to plant our test root certificate in Android trust store to run our certificate verification tests against it.
The patch adds custom test trust store to the java backend, allowing to run the certificate verification tests against custom set of root certificates.
The actual installation of our test root certificate is being done by TestRootCerts class, consistently with what we do on other platforms.
BUG=147786
Review URL: https://chromiumcodereview.appspot.com/11316210
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@172488 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/base')
-rw-r--r-- | net/base/test_root_certs_android.cc | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/net/base/test_root_certs_android.cc b/net/base/test_root_certs_android.cc new file mode 100644 index 0000000..5ad185f --- /dev/null +++ b/net/base/test_root_certs_android.cc @@ -0,0 +1,42 @@ +// 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 "base/location.h" +#include "base/logging.h" +#include "net/android/network_library.h" +#include "net/base/x509_certificate.h" + +namespace net { + +bool TestRootCerts::Add(X509Certificate* certificate) { + std::string cert_bytes; + if (!X509Certificate::GetDEREncoded(certificate->os_cert_handle(), + &cert_bytes)) + return false; + android::AddTestRootCertificate( + reinterpret_cast<const uint8*>(cert_bytes.data()), cert_bytes.size()); + return true; +} + +void TestRootCerts::Clear() { + if (empty_) + return; + + android::ClearTestRootCertificates(); + empty_ = true; +} + +bool TestRootCerts::IsEmpty() const { + return empty_; +} + +TestRootCerts::~TestRootCerts() {} + +void TestRootCerts::Init() { + empty_ = true; +} + +} // namespace net |