OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/ssl_client_certificate_selector.h" | 5 #include "chrome/browser/ssl_client_certificate_selector.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 #include <cryptuiapi.h> | 8 #include <cryptuiapi.h> |
9 #pragma comment(lib, "cryptui.lib") | 9 #pragma comment(lib, "cryptui.lib") |
10 | 10 |
(...skipping 23 matching lines...) Expand all Loading... |
34 HCERTSTORE client_certs = CertOpenStore(CERT_STORE_PROV_MEMORY, 0, NULL, | 34 HCERTSTORE client_certs = CertOpenStore(CERT_STORE_PROV_MEMORY, 0, NULL, |
35 0, NULL); | 35 0, NULL); |
36 BOOL ok; | 36 BOOL ok; |
37 for (size_t i = 0; i < cert_request_info->client_certs.size(); ++i) { | 37 for (size_t i = 0; i < cert_request_info->client_certs.size(); ++i) { |
38 PCCERT_CONTEXT cc = cert_request_info->client_certs[i]->os_cert_handle(); | 38 PCCERT_CONTEXT cc = cert_request_info->client_certs[i]->os_cert_handle(); |
39 ok = CertAddCertificateContextToStore(client_certs, cc, | 39 ok = CertAddCertificateContextToStore(client_certs, cc, |
40 CERT_STORE_ADD_ALWAYS, NULL); | 40 CERT_STORE_ADD_ALWAYS, NULL); |
41 DCHECK(ok); | 41 DCHECK(ok); |
42 } | 42 } |
43 | 43 |
44 std::wstring title = l10n_util::GetString(IDS_CLIENT_CERT_DIALOG_TITLE); | 44 std::wstring title = |
45 std::wstring text = l10n_util::GetStringF( | 45 UTF16ToWide(l10n_util::GetStringUTF16(IDS_CLIENT_CERT_DIALOG_TITLE)); |
| 46 std::wstring text = UTF16ToWide(l10n_util::GetStringFUTF16( |
46 IDS_CLIENT_CERT_DIALOG_TEXT, | 47 IDS_CLIENT_CERT_DIALOG_TEXT, |
47 ASCIIToWide(cert_request_info->host_and_port)); | 48 ASCIIToUTF16(cert_request_info->host_and_port))); |
48 PCCERT_CONTEXT cert_context = CryptUIDlgSelectCertificateFromStore( | 49 PCCERT_CONTEXT cert_context = CryptUIDlgSelectCertificateFromStore( |
49 client_certs, parent->GetMessageBoxRootWindow(), | 50 client_certs, parent->GetMessageBoxRootWindow(), |
50 title.c_str(), text.c_str(), 0, 0, NULL); | 51 title.c_str(), text.c_str(), 0, 0, NULL); |
51 | 52 |
52 net::X509Certificate* cert = NULL; | 53 net::X509Certificate* cert = NULL; |
53 if (cert_context) { | 54 if (cert_context) { |
54 for (size_t i = 0; i < cert_request_info->client_certs.size(); ++i) { | 55 for (size_t i = 0; i < cert_request_info->client_certs.size(); ++i) { |
55 net::X509Certificate* client_cert = cert_request_info->client_certs[i]; | 56 net::X509Certificate* client_cert = cert_request_info->client_certs[i]; |
56 if (net::X509Certificate::IsSameOSCert(cert_context, | 57 if (net::X509Certificate::IsSameOSCert(cert_context, |
57 client_cert->os_cert_handle())) { | 58 client_cert->os_cert_handle())) { |
58 cert = client_cert; | 59 cert = client_cert; |
59 break; | 60 break; |
60 } | 61 } |
61 } | 62 } |
62 DCHECK(cert != NULL); | 63 DCHECK(cert != NULL); |
63 net::X509Certificate::FreeOSCertHandle(cert_context); | 64 net::X509Certificate::FreeOSCertHandle(cert_context); |
64 } | 65 } |
65 | 66 |
66 ok = CertCloseStore(client_certs, CERT_CLOSE_STORE_CHECK_FLAG); | 67 ok = CertCloseStore(client_certs, CERT_CLOSE_STORE_CHECK_FLAG); |
67 DCHECK(ok); | 68 DCHECK(ok); |
68 | 69 |
69 delegate->CertificateSelected(cert); | 70 delegate->CertificateSelected(cert); |
70 } | 71 } |
71 | 72 |
72 } // namespace browser | 73 } // namespace browser |
OLD | NEW |