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

Unified Diff: runtime/bin/secure_socket.cc

Issue 12316036: Merge IO v2 branch to bleeding edge (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebased to r18818 Created 7 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 | « runtime/bin/process_patch.dart ('k') | runtime/bin/secure_socket_patch.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/secure_socket.cc
diff --git a/runtime/bin/secure_socket.cc b/runtime/bin/secure_socket.cc
index 37640eb5cc997dbb2666173912ed1b07640112fb..09b16fb19706fa0de53cc5f30d0ba7d3e176215b 100644
--- a/runtime/bin/secure_socket.cc
+++ b/runtime/bin/secure_socket.cc
@@ -446,17 +446,28 @@ void SSLFilter::Connect(const char* host_name,
SECStatus status;
if (is_server) {
PK11_SetPasswordFunc(PasswordCallback);
- CERTCertDBHandle* certificate_database = CERT_GetDefaultCertDB();
- if (certificate_database == NULL) {
- ThrowPRException("Certificate database cannot be loaded");
- }
- // TODO(whesse): Switch to a function that looks up certs by nickname,
- // so that server and client uses of certificateName agree.
- CERTCertificate* certificate = CERT_FindCertByNameString(
- certificate_database,
- const_cast<char*>(certificate_name));
- if (certificate == NULL) {
- ThrowPRException("Cannot find server certificate by name");
+
+ CERTCertificate* certificate = NULL;
+ if (strstr(certificate_name, "CN=") != NULL) {
+ // Look up certificate using the distinguished name (DN) certificate_name.
+ CERTCertDBHandle* certificate_database = CERT_GetDefaultCertDB();
+ if (certificate_database == NULL) {
+ ThrowPRException("Certificate database cannot be loaded");
+ }
+ certificate = CERT_FindCertByNameString(certificate_database,
+ const_cast<char*>(certificate_name));
+ if (certificate == NULL) {
+ ThrowPRException(
+ "Cannot find server certificate by distinguished name");
+ }
+ } else {
+ // Look up certificate using the nickname certificate_name.
+ certificate = PK11_FindCertFromNickname(
+ const_cast<char*>(certificate_name),
+ static_cast<void*>(const_cast<char*>(password_)));
+ if (certificate == NULL) {
+ ThrowPRException("Cannot find server certificate by nickname");
+ }
}
SECKEYPrivateKey* key = PK11_FindKeyByAnyCert(
certificate,
« no previous file with comments | « runtime/bin/process_patch.dart ('k') | runtime/bin/secure_socket_patch.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698