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

Side by Side Diff: net/socket/ssl_client_socket_mac.cc

Issue 1128008: Mac: Make client-cert picker only show certs the server will accept. (Closed)
Patch Set: Added a test case of parsing T61STRING. Created 10 years, 9 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 unified diff | Download patch
« net/base/x509_certificate_mac.cc ('K') | « net/net.gyp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2008-2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2008-2009 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 "net/socket/ssl_client_socket_mac.h" 5 #include "net/socket/ssl_client_socket_mac.h"
6 6
7 #include <CoreServices/CoreServices.h> 7 #include <CoreServices/CoreServices.h>
8 #include <netdb.h> 8 #include <netdb.h>
9 #include <sys/socket.h> 9 #include <sys/socket.h>
10 #include <sys/types.h> 10 #include <sys/types.h>
(...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after
648 // security info 648 // security info
649 SSLCipherSuite suite; 649 SSLCipherSuite suite;
650 OSStatus status = SSLGetNegotiatedCipher(ssl_context_, &suite); 650 OSStatus status = SSLGetNegotiatedCipher(ssl_context_, &suite);
651 if (!status) 651 if (!status)
652 ssl_info->security_bits = KeySizeOfCipherSuite(suite); 652 ssl_info->security_bits = KeySizeOfCipherSuite(suite);
653 } 653 }
654 654
655 void SSLClientSocketMac::GetSSLCertRequestInfo( 655 void SSLClientSocketMac::GetSSLCertRequestInfo(
656 SSLCertRequestInfo* cert_request_info) { 656 SSLCertRequestInfo* cert_request_info) {
657 // I'm being asked for available client certs (identities). 657 // I'm being asked for available client certs (identities).
658 658 // First, get the cert issuer names allowed by the server.
659 CFArrayRef allowed_issuer_names = NULL; 659 std::vector<CertPrincipal> valid_issuers;
660 if (SSLCopyDistinguishedNames(ssl_context_, &allowed_issuer_names) == noErr && 660 CFArrayRef valid_issuer_names = NULL;
661 allowed_issuer_names != NULL) { 661 if (SSLCopyDistinguishedNames(ssl_context_, &valid_issuer_names) == noErr &&
wtc 2010/03/25 01:00:35 Note: the server may also tell us what kind of cli
662 SSL_LOG << "Server has " << CFArrayGetCount(allowed_issuer_names) 662 valid_issuer_names != NULL) {
663 << " allowed issuer names"; 663 SSL_LOG << "Server has " << CFArrayGetCount(valid_issuer_names)
664 CFRelease(allowed_issuer_names); 664 << " valid issuer names";
665 // TODO(snej): Filter GetSSLClientCertificates using this array. 665 int n = CFArrayGetCount(valid_issuer_names);
wtc 2010/03/24 23:52:05 Nit: move this line up so that in the SSL_LOG stat
666 for (int i = 0; i < n; i++) {
667 // Parse each name into a Principal object.
wtc 2010/03/24 23:52:05 Nit: Principal => CertPrincipal.
668 CFDataRef issuer = reinterpret_cast<CFDataRef>(
669 CFArrayGetValueAtIndex(valid_issuer_names, i));
670 CertPrincipal p;
671 if (p.ParseDistinguishedName(CFDataGetBytePtr(issuer),
672 CFDataGetLength(issuer))) {
673 valid_issuers.push_back(p);
674 }
675 }
676 CFRelease(valid_issuer_names);
666 } 677 }
667 678
679 // Now get the available client certs that match.
wtc 2010/03/24 23:52:05 Nit: match => are issued by the issuers allowed by
668 cert_request_info->host_and_port = hostname_; 680 cert_request_info->host_and_port = hostname_;
669 cert_request_info->client_certs.clear(); 681 cert_request_info->client_certs.clear();
670 X509Certificate::GetSSLClientCertificates(hostname_, 682 X509Certificate::GetSSLClientCertificates(hostname_,
683 valid_issuers,
671 &cert_request_info->client_certs); 684 &cert_request_info->client_certs);
672 SSL_LOG << "Asking user to choose between " 685 SSL_LOG << "Asking user to choose between "
673 << cert_request_info->client_certs.size() << " client certs..."; 686 << cert_request_info->client_certs.size() << " client certs...";
674 } 687 }
675 688
676 SSLClientSocket::NextProtoStatus 689 SSLClientSocket::NextProtoStatus
677 SSLClientSocketMac::GetNextProto(std::string* proto) { 690 SSLClientSocketMac::GetNextProto(std::string* proto) {
678 proto->clear(); 691 proto->clear();
679 return kNextProtoUnsupported; 692 return kNextProtoUnsupported;
680 } 693 }
(...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after
1246 if (rv < 0 && rv != ERR_IO_PENDING) { 1259 if (rv < 0 && rv != ERR_IO_PENDING) {
1247 us->write_io_buf_ = NULL; 1260 us->write_io_buf_ = NULL;
1248 return OSStatusFromNetError(rv); 1261 return OSStatusFromNetError(rv);
1249 } 1262 }
1250 1263
1251 // always lie to our caller 1264 // always lie to our caller
1252 return noErr; 1265 return noErr;
1253 } 1266 }
1254 1267
1255 } // namespace net 1268 } // namespace net
OLDNEW
« net/base/x509_certificate_mac.cc ('K') | « net/net.gyp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698