summaryrefslogtreecommitdiffstats
path: root/net/base/x509_certificate_win.cc
diff options
context:
space:
mode:
authoravi@google.com <avi@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-09-19 20:33:47 +0000
committeravi@google.com <avi@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-09-19 20:33:47 +0000
commit0f7126a5559f831af1285fe353b53fe59f6e5645 (patch)
treeb1262cc12eb4393894cc9c75abf7647e8190e4d4 /net/base/x509_certificate_win.cc
parent793ee1ad634fb9e0d86c8b6625c600d0bc202f22 (diff)
downloadchromium_src-0f7126a5559f831af1285fe353b53fe59f6e5645.zip
chromium_src-0f7126a5559f831af1285fe353b53fe59f6e5645.tar.gz
chromium_src-0f7126a5559f831af1285fe353b53fe59f6e5645.tar.bz2
Add unit test for the X509 parsing. This only runs on Windows, but does so successfully.
Review URL: http://codereview.chromium.org/2993 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@2418 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/base/x509_certificate_win.cc')
-rw-r--r--net/base/x509_certificate_win.cc20
1 files changed, 14 insertions, 6 deletions
diff --git a/net/base/x509_certificate_win.cc b/net/base/x509_certificate_win.cc
index c54ad07..786d09e 100644
--- a/net/base/x509_certificate_win.cc
+++ b/net/base/x509_certificate_win.cc
@@ -319,14 +319,14 @@ X509Certificate* X509Certificate::CreateFromHandle(OSCertHandle cert_handle) {
}
// static
-X509Certificate* X509Certificate::CreateFromBytes(const char* data,
- int length) {
+X509Certificate* X509Certificate::CreateFromBytes(const char* data, int length) {
OSCertHandle cert_handle = NULL;
- if (!CertAddSerializedElementToStore(
+ if (!CertAddEncodedCertificateToStore(
NULL, // the cert won't be persisted in any cert store
+ X509_ASN_ENCODING,
reinterpret_cast<const BYTE*>(data), length,
- CERT_STORE_ADD_USE_EXISTING, 0, CERT_STORE_CERTIFICATE_CONTEXT_FLAG,
- NULL, reinterpret_cast<const void **>(&cert_handle)))
+ CERT_STORE_ADD_USE_EXISTING,
+ &cert_handle))
return NULL;
return CreateFromHandle(cert_handle);
@@ -340,7 +340,15 @@ X509Certificate* X509Certificate::CreateFromPickle(const Pickle& pickle,
if (!pickle.ReadData(pickle_iter, &data, &length))
return NULL;
- return CreateFromBytes(data, length);
+ OSCertHandle cert_handle = NULL;
+ if (!CertAddSerializedElementToStore(
+ NULL, // the cert won't be persisted in any cert store
+ reinterpret_cast<const BYTE*>(data), length,
+ CERT_STORE_ADD_USE_EXISTING, 0, CERT_STORE_CERTIFICATE_CONTEXT_FLAG,
+ NULL, reinterpret_cast<const void **>(&cert_handle)))
+ return NULL;
+
+ return CreateFromHandle(cert_handle);
}
X509Certificate::X509Certificate(OSCertHandle cert_handle)