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

Unified Diff: net/base/x509_certificate_win.cc

Issue 4645001: Change the HTTP cache to cache the entire certificate chain for SSL sites (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/net/base
Patch Set: Rebase before commit Created 9 years, 8 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
Index: net/base/x509_certificate_win.cc
diff --git a/net/base/x509_certificate_win.cc b/net/base/x509_certificate_win.cc
index a1a3eae3d5852b95e83d466f4cc2016d11e17f1d..fd5076d3353639739a4f79043f62e557ee71684d 100644
--- a/net/base/x509_certificate_win.cc
+++ b/net/base/x509_certificate_win.cc
@@ -550,29 +550,6 @@ bool X509Certificate::IsIssuedByKnownRoot(PCCERT_CHAIN_CONTEXT chain_context) {
}
// static
-X509Certificate* X509Certificate::CreateFromPickle(const Pickle& pickle,
- void** pickle_iter) {
- const char* data;
- int length;
- if (!pickle.ReadData(pickle_iter, &data, &length))
- return NULL;
-
- 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;
-
- X509Certificate* cert = CreateFromHandle(cert_handle,
- SOURCE_LONE_CERT_IMPORT,
- OSCertHandles());
- FreeOSCertHandle(cert_handle);
- return cert;
-}
-
-// static
X509Certificate* X509Certificate::CreateSelfSigned(
crypto::RSAPrivateKey* key,
const std::string& subject,
@@ -635,23 +612,6 @@ X509Certificate* X509Certificate::CreateSelfSigned(
return cert;
}
-void X509Certificate::Persist(Pickle* pickle) {
- DCHECK(cert_handle_);
- DWORD length;
- if (!CertSerializeCertificateStoreElement(cert_handle_, 0,
- NULL, &length)) {
- NOTREACHED();
- return;
- }
- BYTE* data = reinterpret_cast<BYTE*>(pickle->BeginWriteData(length));
- if (!CertSerializeCertificateStoreElement(cert_handle_, 0,
- data, &length)) {
- NOTREACHED();
- length = 0;
- }
- pickle->TrimWriteData(length);
-}
-
void X509Certificate::GetDNSNames(std::vector<std::string>* dns_names) const {
dns_names->clear();
if (cert_handle_) {
@@ -1044,4 +1004,45 @@ SHA1Fingerprint X509Certificate::CalculateFingerprint(
return sha1;
}
+// static
+X509Certificate::OSCertHandle
+X509Certificate::ReadCertHandleFromPickle(const Pickle& pickle,
+ void** pickle_iter) {
+ const char* data;
+ int length;
+ if (!pickle.ReadData(pickle_iter, &data, &length))
+ return NULL;
+
+ 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 cert_handle;
+}
+
+// static
+bool X509Certificate::WriteCertHandleToPickle(OSCertHandle cert_handle,
+ Pickle* pickle) {
+ DWORD length = 0;
+ if (!CertSerializeCertificateStoreElement(cert_handle, 0, NULL, &length))
+ return false;
+
+ std::vector<BYTE> buffer(length);
+ // Serialize |cert_handle| in a way that will preserve any extended
+ // attributes set on the handle, such as the location to the certificate's
+ // private key.
+ if (!CertSerializeCertificateStoreElement(cert_handle, 0, &buffer[0],
+ &length)) {
+ return false;
+ }
+
+ return pickle->WriteData(reinterpret_cast<const char*>(&buffer[0]),
+ length);
wtc 2011/04/20 23:07:58 Why don't you use the original code (pickle->Begin
Ryan Sleevi 2011/04/20 23:59:10 Per pickle.cc, there can only be one variable buff
+}
+
} // namespace net

Powered by Google App Engine
This is Rietveld 408576698