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

Unified Diff: net/socket/ssl_client_socket_win.cc

Issue 2944008: Refactor X509Certificate caching to cache the OS handle, rather than the X509Certificate (Closed)
Patch Set: Rebase before commit Created 9 years, 5 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 | « net/socket/ssl_client_socket_openssl.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/socket/ssl_client_socket_win.cc
diff --git a/net/socket/ssl_client_socket_win.cc b/net/socket/ssl_client_socket_win.cc
index 4cc310357da2bcf74952aded6f5aeafc7fcca17c..ecdf8cfd892d433ab4c429306ee2ebc6d8b4e829 100644
--- a/net/socket/ssl_client_socket_win.cc
+++ b/net/socket/ssl_client_socket_win.cc
@@ -337,40 +337,6 @@ static BOOL WINAPI ClientCertFindCallback(PCCERT_CONTEXT cert_context,
//-----------------------------------------------------------------------------
-// A memory certificate store for client certificates. This allows us to
-// close the "MY" system certificate store when we finish searching for
-// client certificates.
-class ClientCertStore {
- public:
- ClientCertStore() {
- store_ = CertOpenStore(CERT_STORE_PROV_MEMORY, 0, NULL, 0, NULL);
- }
-
- ~ClientCertStore() {
- if (store_) {
- BOOL ok = CertCloseStore(store_, CERT_CLOSE_STORE_CHECK_FLAG);
- DCHECK(ok);
- }
- }
-
- PCCERT_CONTEXT CopyCertContext(PCCERT_CONTEXT client_cert) {
- PCCERT_CONTEXT copy;
- BOOL ok = CertAddCertificateContextToStore(store_, client_cert,
- CERT_STORE_ADD_USE_EXISTING,
- &copy);
- DCHECK(ok);
- return ok ? copy : NULL;
- }
-
- private:
- HCERTSTORE store_;
-};
-
-static base::LazyInstance<ClientCertStore> g_client_cert_store(
- base::LINKER_INITIALIZED);
-
-//-----------------------------------------------------------------------------
-
// Size of recv_buffer_
//
// Ciphertext is decrypted one SSL record at a time, so recv_buffer_ needs to
@@ -522,17 +488,18 @@ void SSLClientSocketWin::GetSSLCertRequestInfo(
// Get the leaf certificate.
PCCERT_CONTEXT cert_context =
chain_context->rgpChain[0]->rgpElement[0]->pCertContext;
- // Copy it to our own certificate store, so that we can close the "MY"
- // certificate store before returning from this function.
- PCCERT_CONTEXT cert_context2 =
- g_client_cert_store.Get().CopyCertContext(cert_context);
- if (!cert_context2) {
+ // Copy the certificate into a NULL store, so that we can close the "MY"
+ // store before returning from this function.
+ PCCERT_CONTEXT cert_context2 = NULL;
+ BOOL ok = CertAddCertificateContextToStore(NULL, cert_context,
+ CERT_STORE_ADD_USE_EXISTING,
+ &cert_context2);
+ if (!ok) {
NOTREACHED();
continue;
}
scoped_refptr<X509Certificate> cert = X509Certificate::CreateFromHandle(
- cert_context2, X509Certificate::SOURCE_LONE_CERT_IMPORT,
- X509Certificate::OSCertHandles());
+ cert_context2, X509Certificate::OSCertHandles());
cert_request_info->client_certs.push_back(cert);
CertFreeCertificateContext(cert_context2);
}
@@ -1514,8 +1481,7 @@ int SSLClientSocketWin::DidCompleteHandshake() {
DidCompleteRenegotiation();
} else {
server_cert_ = X509Certificate::CreateFromHandle(
- server_cert_handle, X509Certificate::SOURCE_FROM_NETWORK,
- X509Certificate::OSCertHandles());
+ server_cert_handle, X509Certificate::OSCertHandles());
next_state_ = STATE_VERIFY_CERT;
}
« no previous file with comments | « net/socket/ssl_client_socket_openssl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698