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

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

Issue 11739004: Add server certificate request parameters to be stored in SSLCertRequestInfo. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Address Ryan's remark ( ASSERT_TRUE(ptr) ) Created 7 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 unified diff | Download patch
« no previous file with comments | « net/base/test_data_directory.cc ('k') | net/socket/ssl_client_socket_nss.cc » ('j') | 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 730 matching lines...) Expand 10 before | Expand all | Expand 10 after
741 } 741 }
742 742
743 if (ssl_config_.version_fallback) 743 if (ssl_config_.version_fallback)
744 ssl_info->connection_status |= SSL_CONNECTION_VERSION_FALLBACK; 744 ssl_info->connection_status |= SSL_CONNECTION_VERSION_FALLBACK;
745 745
746 return true; 746 return true;
747 } 747 }
748 748
749 void SSLClientSocketMac::GetSSLCertRequestInfo( 749 void SSLClientSocketMac::GetSSLCertRequestInfo(
750 SSLCertRequestInfo* cert_request_info) { 750 SSLCertRequestInfo* cert_request_info) {
751 // I'm being asked for available client certs (identities). 751 cert_request_info->host_and_port = host_and_port_.ToString();
752 // First, get the cert issuer names allowed by the server. 752 cert_request_info->cert_authorities.clear();
753 cert_request_info->cert_key_types.clear();
754 cert_request_info->client_certs.clear();
755
756 // Retrieve the cert issuers accepted by the server. This information is
757 // currently (temporarily) being saved both in |valid_issuers| and
758 // |cert_authorities|, the latter being the target solution. The refactoring
759 // effort is being tracked in http://crbug.com/166642.
753 std::vector<CertPrincipal> valid_issuers; 760 std::vector<CertPrincipal> valid_issuers;
754 CFArrayRef valid_issuer_names = NULL; 761 CFArrayRef valid_issuer_names = NULL;
755 if (SSLCopyDistinguishedNames(ssl_context_, &valid_issuer_names) == noErr && 762 if (SSLCopyDistinguishedNames(ssl_context_, &valid_issuer_names) == noErr &&
756 valid_issuer_names != NULL) { 763 valid_issuer_names != NULL) {
757 VLOG(1) << "Server has " << CFArrayGetCount(valid_issuer_names) 764 VLOG(1) << "Server has " << CFArrayGetCount(valid_issuer_names)
758 << " valid issuer names"; 765 << " valid issuer names";
759 int n = CFArrayGetCount(valid_issuer_names); 766 int n = CFArrayGetCount(valid_issuer_names);
760 for (int i = 0; i < n; i++) { 767 for (int i = 0; i < n; i++) {
761 // Parse each name into a CertPrincipal object.
762 CFDataRef issuer = reinterpret_cast<CFDataRef>( 768 CFDataRef issuer = reinterpret_cast<CFDataRef>(
763 CFArrayGetValueAtIndex(valid_issuer_names, i)); 769 CFArrayGetValueAtIndex(valid_issuer_names, i));
770 // Add the DER-encoded issuer DistinguishedName to |cert_authorities|.
771 cert_request_info->cert_authorities.push_back(std::string(
772 reinterpret_cast<const char*>(CFDataGetBytePtr(issuer)),
773 static_cast<size_t>(CFDataGetLength(issuer))));
774 // Add the CertPrincipal object representing the issuer to
775 // |valid_issuers|.
764 CertPrincipal p; 776 CertPrincipal p;
765 if (p.ParseDistinguishedName(CFDataGetBytePtr(issuer), 777 if (p.ParseDistinguishedName(CFDataGetBytePtr(issuer),
766 CFDataGetLength(issuer))) { 778 CFDataGetLength(issuer))) {
767 valid_issuers.push_back(p); 779 valid_issuers.push_back(p);
768 } 780 }
769 } 781 }
770 CFRelease(valid_issuer_names); 782 CFRelease(valid_issuer_names);
771 } 783 }
772 784
773 // Now get the available client certs whose issuers are allowed by the server. 785 // Now get the available client certs whose issuers are allowed by the server.
774 cert_request_info->host_and_port = host_and_port_.ToString();
775 cert_request_info->client_certs.clear();
776 // TODO(rch): we should consider passing a host-port pair as the first 786 // TODO(rch): we should consider passing a host-port pair as the first
777 // argument to X509Certificate::GetSSLClientCertificates. 787 // argument to X509Certificate::GetSSLClientCertificates.
778 X509Certificate::GetSSLClientCertificates(host_and_port_.host(), 788 X509Certificate::GetSSLClientCertificates(host_and_port_.host(),
779 valid_issuers, 789 valid_issuers,
780 &cert_request_info->client_certs); 790 &cert_request_info->client_certs);
781 std::sort(cert_request_info->client_certs.begin(), 791 std::sort(cert_request_info->client_certs.begin(),
782 cert_request_info->client_certs.end(), 792 cert_request_info->client_certs.end(),
783 x509_util::ClientCertSorter()); 793 x509_util::ClientCertSorter());
784 794
785 VLOG(1) << "Asking user to choose between " 795 VLOG(1) << "Asking user to choose between "
(...skipping 666 matching lines...) Expand 10 before | Expand all | Expand 10 after
1452 if (rv < 0 && rv != ERR_IO_PENDING) { 1462 if (rv < 0 && rv != ERR_IO_PENDING) {
1453 us->write_io_buf_ = NULL; 1463 us->write_io_buf_ = NULL;
1454 return OSStatusFromNetError(rv); 1464 return OSStatusFromNetError(rv);
1455 } 1465 }
1456 1466
1457 // always lie to our caller 1467 // always lie to our caller
1458 return noErr; 1468 return noErr;
1459 } 1469 }
1460 1470
1461 } // namespace net 1471 } // namespace net
OLDNEW
« no previous file with comments | « net/base/test_data_directory.cc ('k') | net/socket/ssl_client_socket_nss.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698