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

Unified Diff: net/socket/ssl_client_socket_nss.cc

Issue 4670004: Change NSS's native auth patch to use PCERT_KEY_CONTEXT instead of HCRYPTPROV on Win (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase to trunk Created 9 years, 11 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/third_party/nss/ssl/ssl.h » ('j') | net/third_party/nss/ssl/ssl.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/socket/ssl_client_socket_nss.cc
diff --git a/net/socket/ssl_client_socket_nss.cc b/net/socket/ssl_client_socket_nss.cc
index d006d58ad8296a464ccc49f7154d43cf4bbfde1a..ad42560cefdf84e44e3f8a5b162f3ddfb33b3ba0 100644
--- a/net/socket/ssl_client_socket_nss.cc
+++ b/net/socket/ssl_client_socket_nss.cc
@@ -1536,69 +1536,30 @@ SECStatus SSLClientSocketNSS::PlatformClientAuthHandler(
if (that->ssl_config_.client_cert) {
PCCERT_CONTEXT cert_context =
that->ssl_config_.client_cert->os_cert_handle();
- if (VLOG_IS_ON(1)) {
- do {
- DWORD size_needed = 0;
- BOOL got_info = CertGetCertificateContextProperty(
- cert_context, CERT_KEY_PROV_INFO_PROP_ID, NULL, &size_needed);
- if (!got_info) {
- VLOG(1) << "Failed to get key prov info size " << GetLastError();
- break;
- }
- std::vector<BYTE> raw_info(size_needed);
- got_info = CertGetCertificateContextProperty(
- cert_context, CERT_KEY_PROV_INFO_PROP_ID, &raw_info[0],
- &size_needed);
- if (!got_info) {
- VLOG(1) << "Failed to get key prov info " << GetLastError();
- break;
- }
- PCRYPT_KEY_PROV_INFO info =
- reinterpret_cast<PCRYPT_KEY_PROV_INFO>(&raw_info[0]);
- VLOG(1) << "Container Name: " << info->pwszContainerName
- << "\nProvider Name: " << info->pwszProvName
- << "\nProvider Type: " << info->dwProvType
- << "\nFlags: " << info->dwFlags
- << "\nProvider Param Count: " << info->cProvParam
- << "\nKey Specifier: " << info->dwKeySpec;
- } while (false);
-
- do {
- DWORD size_needed = 0;
- BOOL got_identifier = CertGetCertificateContextProperty(
- cert_context, CERT_KEY_IDENTIFIER_PROP_ID, NULL, &size_needed);
- if (!got_identifier) {
- VLOG(1) << "Failed to get key identifier size "
- << GetLastError();
- break;
- }
- std::vector<BYTE> raw_id(size_needed);
- got_identifier = CertGetCertificateContextProperty(
- cert_context, CERT_KEY_IDENTIFIER_PROP_ID, &raw_id[0],
- &size_needed);
- if (!got_identifier) {
- VLOG(1) << "Failed to get key identifier " << GetLastError();
- break;
- }
- VLOG(1) << "Key Identifier: " << base::HexEncode(&raw_id[0],
- size_needed);
- } while (false);
+ CERT_KEY_CONTEXT* key_context = reinterpret_cast<CERT_KEY_CONTEXT*>(
+ PORT_Alloc(sizeof(CERT_KEY_CONTEXT)));
+ if (!key_context) {
+ LOG(ERROR) << "Internal NSS allocation error";
wtc 2011/02/04 01:32:16 Remove this error message, partly because PORT_All
+ return SECFailure;
}
+ memset(key_context, 0, sizeof(*key_context));
wtc 2011/02/04 01:32:16 You can use PORT_ZAlloc() instead, which returns z
+ key_context->cbSize = sizeof(*key_context);
+
HCRYPTPROV provider = NULL;
wtc 2011/02/04 01:32:16 Delete 'provider'.
- DWORD key_spec = AT_KEYEXCHANGE;
BOOL must_free = FALSE;
BOOL acquired_key = CryptAcquireCertificatePrivateKey(
cert_context,
CRYPT_ACQUIRE_CACHE_FLAG | CRYPT_ACQUIRE_COMPARE_KEY_FLAG,
- NULL, &provider, &key_spec, &must_free);
- if (acquired_key && provider) {
- DCHECK_NE(key_spec, CERT_NCRYPT_KEY_SPEC);
+ NULL, &key_context->hCryptProv, &key_context->dwKeySpec,
+ &must_free);
+ if (acquired_key && key_context->hCryptProv) {
+ DCHECK_NE(key_context->dwKeySpec, CERT_NCRYPT_KEY_SPEC);
// The certificate cache may have been updated/used, in which case,
// duplicate the existing handle, since NSS will free it when no
// longer in use.
if (!must_free)
- CryptContextAddRef(provider, NULL, 0);
+ CryptContextAddRef(key_context->hCryptProv, NULL, 0);
SECItem der_cert;
der_cert.type = siDERCertBuffer;
@@ -1624,10 +1585,10 @@ SECStatus SSLClientSocketNSS::PlatformClientAuthHandler(
db_handle, &der_cert, NULL, PR_FALSE, PR_TRUE);
CERT_AddCertToListTail(*result_certs, intermediate);
}
- // TODO(wtc): |key_spec| should be passed along with |provider|.
- *result_private_key = reinterpret_cast<void*>(provider);
+ *result_private_key = reinterpret_cast<void*>(key_context);
wtc 2011/02/04 01:32:16 I believe this reinterpret_cast<void*> can be remo
return SECSuccess;
}
+ PORT_Free(key_context);
LOG(WARNING) << "Client cert found without private key";
}
// Send no client certificate.
« no previous file with comments | « no previous file | net/third_party/nss/ssl/ssl.h » ('j') | net/third_party/nss/ssl/ssl.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698