OLD | NEW |
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 Loading... |
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 // First, get the cert issuer names allowed by the server. | 658 |
659 std::vector<CertPrincipal> valid_issuers; | 659 CFArrayRef allowed_issuer_names = NULL; |
660 CFArrayRef valid_issuer_names = NULL; | 660 if (SSLCopyDistinguishedNames(ssl_context_, &allowed_issuer_names) == noErr && |
661 if (SSLCopyDistinguishedNames(ssl_context_, &valid_issuer_names) == noErr && | 661 allowed_issuer_names != NULL) { |
662 valid_issuer_names != NULL) { | 662 SSL_LOG << "Server has " << CFArrayGetCount(allowed_issuer_names) |
663 SSL_LOG << "Server has " << CFArrayGetCount(valid_issuer_names) | 663 << " allowed issuer names"; |
664 << " valid issuer names"; | 664 CFRelease(allowed_issuer_names); |
665 int n = CFArrayGetCount(valid_issuer_names); | 665 // TODO(snej): Filter GetSSLClientCertificates using this array. |
666 for (int i = 0; i < n; i++) { | |
667 // Parse each name into a CertPrincipal object. | |
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); | |
677 } | 666 } |
678 | 667 |
679 // Now get the available client certs whose issuers are allowed by the server. | |
680 cert_request_info->host_and_port = hostname_; | 668 cert_request_info->host_and_port = hostname_; |
681 cert_request_info->client_certs.clear(); | 669 cert_request_info->client_certs.clear(); |
682 X509Certificate::GetSSLClientCertificates(hostname_, | 670 X509Certificate::GetSSLClientCertificates(hostname_, |
683 valid_issuers, | |
684 &cert_request_info->client_certs); | 671 &cert_request_info->client_certs); |
685 SSL_LOG << "Asking user to choose between " | 672 SSL_LOG << "Asking user to choose between " |
686 << cert_request_info->client_certs.size() << " client certs..."; | 673 << cert_request_info->client_certs.size() << " client certs..."; |
687 } | 674 } |
688 | 675 |
689 SSLClientSocket::NextProtoStatus | 676 SSLClientSocket::NextProtoStatus |
690 SSLClientSocketMac::GetNextProto(std::string* proto) { | 677 SSLClientSocketMac::GetNextProto(std::string* proto) { |
691 proto->clear(); | 678 proto->clear(); |
692 return kNextProtoUnsupported; | 679 return kNextProtoUnsupported; |
693 } | 680 } |
(...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1259 if (rv < 0 && rv != ERR_IO_PENDING) { | 1246 if (rv < 0 && rv != ERR_IO_PENDING) { |
1260 us->write_io_buf_ = NULL; | 1247 us->write_io_buf_ = NULL; |
1261 return OSStatusFromNetError(rv); | 1248 return OSStatusFromNetError(rv); |
1262 } | 1249 } |
1263 | 1250 |
1264 // always lie to our caller | 1251 // always lie to our caller |
1265 return noErr; | 1252 return noErr; |
1266 } | 1253 } |
1267 | 1254 |
1268 } // namespace net | 1255 } // namespace net |
OLD | NEW |