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

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

Issue 10830326: net: disable ECDSA ciphersuites on platforms where we can't support it. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « net/socket/ssl_client_socket_nss.h ('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) 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 // This file includes code SSLClientSocketNSS::DoVerifyCertComplete() derived 5 // This file includes code SSLClientSocketNSS::DoVerifyCertComplete() derived
6 // from AuthCertificateCallback() in 6 // from AuthCertificateCallback() in
7 // mozilla/security/manager/ssl/src/nsNSSCallbacks.cpp. 7 // mozilla/security/manager/ssl/src/nsNSSCallbacks.cpp.
8 8
9 /* ***** BEGIN LICENSE BLOCK ***** 9 /* ***** BEGIN LICENSE BLOCK *****
10 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 10 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 #include "net/base/ssl_info.h" 101 #include "net/base/ssl_info.h"
102 #include "net/base/x509_certificate_net_log_param.h" 102 #include "net/base/x509_certificate_net_log_param.h"
103 #include "net/ocsp/nss_ocsp.h" 103 #include "net/ocsp/nss_ocsp.h"
104 #include "net/socket/client_socket_handle.h" 104 #include "net/socket/client_socket_handle.h"
105 #include "net/socket/nss_ssl_util.h" 105 #include "net/socket/nss_ssl_util.h"
106 #include "net/socket/ssl_error_params.h" 106 #include "net/socket/ssl_error_params.h"
107 107
108 #if defined(OS_WIN) 108 #if defined(OS_WIN)
109 #include <windows.h> 109 #include <windows.h>
110 #include <wincrypt.h> 110 #include <wincrypt.h>
111 #include "base/win/windows_version.h"
111 #elif defined(OS_MACOSX) 112 #elif defined(OS_MACOSX)
112 #include <Security/SecBase.h> 113 #include <Security/SecBase.h>
113 #include <Security/SecCertificate.h> 114 #include <Security/SecCertificate.h>
114 #include <Security/SecIdentity.h> 115 #include <Security/SecIdentity.h>
115 #include "base/mac/mac_logging.h" 116 #include "base/mac/mac_logging.h"
117 #include "base/mac/mac_util.h"
116 #elif defined(USE_NSS) 118 #elif defined(USE_NSS)
117 #include <dlfcn.h> 119 #include <dlfcn.h>
118 #endif 120 #endif
119 121
120 static const int kRecvBufferSize = 4096; 122 static const int kRecvBufferSize = 4096;
121 123
122 #if defined(OS_WIN) 124 #if defined(OS_WIN)
123 // CERT_OCSP_RESPONSE_PROP_ID is only implemented on Vista+, but it can be 125 // CERT_OCSP_RESPONSE_PROP_ID is only implemented on Vista+, but it can be
124 // set on Windows XP without error. There is some overhead from the server 126 // set on Windows XP without error. There is some overhead from the server
125 // sending the OCSP response if it supports the extension, for the subset of 127 // sending the OCSP response if it supports the extension, for the subset of
(...skipping 2981 matching lines...) Expand 10 before | Expand all | Expand 10 after
3107 } 3109 }
3108 3110
3109 for (std::vector<uint16>::const_iterator it = 3111 for (std::vector<uint16>::const_iterator it =
3110 ssl_config_.disabled_cipher_suites.begin(); 3112 ssl_config_.disabled_cipher_suites.begin();
3111 it != ssl_config_.disabled_cipher_suites.end(); ++it) { 3113 it != ssl_config_.disabled_cipher_suites.end(); ++it) {
3112 // This will fail if the specified cipher is not implemented by NSS, but 3114 // This will fail if the specified cipher is not implemented by NSS, but
3113 // the failure is harmless. 3115 // the failure is harmless.
3114 SSL_CipherPrefSet(nss_fd_, *it, PR_FALSE); 3116 SSL_CipherPrefSet(nss_fd_, *it, PR_FALSE);
3115 } 3117 }
3116 3118
3119 // On some platforms we cannot verify ECDSA certificates.
3120 #if defined(OS_WIN)
3121 if (base::win::GetVersion() < base::win::VISTA) {
3122 DisableECDSA();
3123 }
3124 #elif defined(OS_MACOSX)
3125 if (!base::mac::IsOSSnowLeopardOrLater()) {
3126 DisableECDSA();
3127 }
3128 #endif
Ryan Sleevi 2012/08/15 00:40:27 Seems like you can move this into NSSSSLInitSingle
agl 2012/08/15 01:06:20 Good point, there's a SetDefault function too. Don
3129
3117 #ifdef SSL_ENABLE_SESSION_TICKETS 3130 #ifdef SSL_ENABLE_SESSION_TICKETS
3118 // Support RFC 5077 3131 // Support RFC 5077
3119 rv = SSL_OptionSet(nss_fd_, SSL_ENABLE_SESSION_TICKETS, PR_TRUE); 3132 rv = SSL_OptionSet(nss_fd_, SSL_ENABLE_SESSION_TICKETS, PR_TRUE);
3120 if (rv != SECSuccess) { 3133 if (rv != SECSuccess) {
3121 LogFailedNSSFunction( 3134 LogFailedNSSFunction(
3122 net_log_, "SSL_OptionSet", "SSL_ENABLE_SESSION_TICKETS"); 3135 net_log_, "SSL_OptionSet", "SSL_ENABLE_SESSION_TICKETS");
3123 } 3136 }
3124 #else 3137 #else
3125 #error "You need to install NSS-3.12 or later to build chromium" 3138 #error "You need to install NSS-3.12 or later to build chromium"
3126 #endif 3139 #endif
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
3503 return; 3516 return;
3504 valid_thread_id_ = base::PlatformThread::CurrentId(); 3517 valid_thread_id_ = base::PlatformThread::CurrentId();
3505 } 3518 }
3506 3519
3507 bool SSLClientSocketNSS::CalledOnValidThread() const { 3520 bool SSLClientSocketNSS::CalledOnValidThread() const {
3508 EnsureThreadIdAssigned(); 3521 EnsureThreadIdAssigned();
3509 base::AutoLock auto_lock(lock_); 3522 base::AutoLock auto_lock(lock_);
3510 return valid_thread_id_ == base::PlatformThread::CurrentId(); 3523 return valid_thread_id_ == base::PlatformThread::CurrentId();
3511 } 3524 }
3512 3525
3526 void SSLClientSocketNSS::DisableECDSA() {
3527 const PRUint16* ciphersuites = SSL_GetImplementedCiphers();
3528 const unsigned num_ciphersuites = SSL_GetNumImplementedCiphers();
3529 SECStatus rv;
3530 SSLCipherSuiteInfo info;
3531
3532 for (unsigned i = 0; i < num_ciphersuites; i++) {
3533 rv = SSL_GetCipherSuiteInfo(ciphersuites[i], &info, sizeof(info));
3534 if (rv != SECSuccess) {
3535 LogFailedNSSFunction(net_log_, "SSL_GetCipherSuiteInfo", "");
3536 LOG(ERROR) << "SSL_GetCipherSuiteInfo failed";
3537 break;
3538 }
3539 if (info.authAlgorithm == ssl_auth_ecdsa) {
3540 SSL_CipherPrefSet(nss_fd_, ciphersuites[i], PR_FALSE);
3541 }
3542 }
3543 }
3544
3513 ServerBoundCertService* SSLClientSocketNSS::GetServerBoundCertService() const { 3545 ServerBoundCertService* SSLClientSocketNSS::GetServerBoundCertService() const {
3514 return server_bound_cert_service_; 3546 return server_bound_cert_service_;
3515 } 3547 }
3516 3548
3517 } // namespace net 3549 } // namespace net
OLDNEW
« no previous file with comments | « net/socket/ssl_client_socket_nss.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698