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

Unified Diff: net/base/x509_certificate_nss.cc

Issue 27033: Implement X509Certificate::Persist. This fixes gmail on linux. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 11 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | net/base/x509_certificate_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/x509_certificate_nss.cc
===================================================================
--- net/base/x509_certificate_nss.cc (revision 10264)
+++ net/base/x509_certificate_nss.cc (working copy)
@@ -14,6 +14,7 @@
#undef Lock
#include "base/logging.h"
+#include "base/pickle.h"
#include "base/time.h"
#include "base/nss_init.h"
#include "net/base/net_errors.h"
@@ -26,7 +27,7 @@
base::Time PRTimeToBaseTime(PRTime prtime) {
PRExplodedTime prxtime;
PR_ExplodeTime(prtime, PR_GMTParameters, &prxtime);
-
+
base::Time::Exploded exploded;
exploded.year = prxtime.tm_year;
exploded.month = prxtime.tm_month + 1;
@@ -36,7 +37,7 @@
exploded.minute = prxtime.tm_min;
exploded.second = prxtime.tm_sec;
exploded.millisecond = prxtime.tm_usec / 1000;
-
+
return base::Time::FromUTCExploded(exploded);
}
@@ -64,7 +65,7 @@
country_names;
// TODO(jcampan): add business_category and serial_number.
- static const SECOidTag kOIDs[] = {
+ static const SECOidTag kOIDs[] = {
SEC_OID_AVA_COMMON_NAME,
SEC_OID_AVA_LOCALITY,
SEC_OID_AVA_STATE_OR_PROVINCE,
@@ -93,7 +94,7 @@
SECItem* decode_item = CERT_DecodeAVAValue(&avas[pair]->value);
if (!decode_item)
break;
- std::string value(reinterpret_cast<char*>(decode_item->data),
+ std::string value(reinterpret_cast<char*>(decode_item->data),
decode_item->len);
values[oid]->push_back(value);
SECITEM_FreeItem(decode_item, PR_TRUE);
@@ -128,7 +129,7 @@
CERTGeneralNameType name_type,
std::vector<std::string>* result) {
- SECItem alt_name;
+ SECItem alt_name;
SECStatus rv = CERT_FindCertExtension(cert_handle,
SEC_OID_X509_SUBJECT_ALT_NAME, &alt_name);
if (rv != SECSuccess)
@@ -168,7 +169,7 @@
ParseDate(&cert_handle_->validity.notBefore, &valid_start_);
ParseDate(&cert_handle_->validity.notAfter, &valid_expiry_);
-
+
fingerprint_ = CalculateFingerprint(cert_handle_);
// Store the certificate in the cache in case we need it later.
@@ -178,15 +179,17 @@
// static
X509Certificate* X509Certificate::CreateFromPickle(const Pickle& pickle,
void** pickle_iter) {
- NOTIMPLEMENTED();
- return NULL;
+ const char* data;
+ int length;
+ if (!pickle.ReadData(pickle_iter, &data, &length))
+ return NULL;
+
+ return CreateFromBytes(data, length);
}
void X509Certificate::Persist(Pickle* pickle) {
- // TODO(port): implement.
-
- // Calling NOTIMPLEMENTED here breaks webkit tests.
- //NOTIMPLEMENTED();
+ pickle->WriteData(reinterpret_cast<const char*>(cert_handle_->derCert.data),
+ cert_handle_->derCert.len);
}
void X509Certificate::GetDNSNames(std::vector<std::string>* dns_names) const {
@@ -194,7 +197,7 @@
// Compare with CERT_VerifyCertName().
GetCertSubjectAltNamesOfType(cert_handle_, certDNSName, dns_names);
-
+
// TODO(port): suppress nss's support of the obsolete extension
// SEC_OID_NS_CERT_EXT_SSL_SERVER_NAME
// by providing our own authCertificate callback.
@@ -247,6 +250,6 @@
return sha1;
}
-
+
} // namespace net
« no previous file with comments | « no previous file | net/base/x509_certificate_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698