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

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

Issue 1421903008: Revert of SSL in EmbeddedTestServer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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/socket/ssl_server_socket_openssl.h ('k') | net/socket/ssl_server_socket_unittest.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_server_socket_openssl.h" 5 #include "net/socket/ssl_server_socket_openssl.h"
6 6
7 #include <openssl/err.h> 7 #include <openssl/err.h>
8 #include <openssl/ssl.h> 8 #include <openssl/ssl.h>
9 9
10 #include "base/callback_helpers.h" 10 #include "base/callback_helpers.h"
(...skipping 11 matching lines...) Expand all
22 namespace net { 22 namespace net {
23 23
24 void EnableSSLServerSockets() { 24 void EnableSSLServerSockets() {
25 // No-op because CreateSSLServerSocket() calls crypto::EnsureOpenSSLInit(). 25 // No-op because CreateSSLServerSocket() calls crypto::EnsureOpenSSLInit().
26 } 26 }
27 27
28 scoped_ptr<SSLServerSocket> CreateSSLServerSocket( 28 scoped_ptr<SSLServerSocket> CreateSSLServerSocket(
29 scoped_ptr<StreamSocket> socket, 29 scoped_ptr<StreamSocket> socket,
30 X509Certificate* certificate, 30 X509Certificate* certificate,
31 crypto::RSAPrivateKey* key, 31 crypto::RSAPrivateKey* key,
32 const SSLServerConfig& ssl_config) { 32 const SSLConfig& ssl_config) {
33 crypto::EnsureOpenSSLInit(); 33 crypto::EnsureOpenSSLInit();
34 return scoped_ptr<SSLServerSocket>( 34 return scoped_ptr<SSLServerSocket>(
35 new SSLServerSocketOpenSSL(socket.Pass(), certificate, key, ssl_config)); 35 new SSLServerSocketOpenSSL(socket.Pass(), certificate, key, ssl_config));
36 } 36 }
37 37
38 SSLServerSocketOpenSSL::SSLServerSocketOpenSSL( 38 SSLServerSocketOpenSSL::SSLServerSocketOpenSSL(
39 scoped_ptr<StreamSocket> transport_socket, 39 scoped_ptr<StreamSocket> transport_socket,
40 scoped_refptr<X509Certificate> certificate, 40 scoped_refptr<X509Certificate> certificate,
41 crypto::RSAPrivateKey* key, 41 crypto::RSAPrivateKey* key,
42 const SSLServerConfig& ssl_config) 42 const SSLConfig& ssl_config)
43 : transport_send_busy_(false), 43 : transport_send_busy_(false),
44 transport_recv_busy_(false), 44 transport_recv_busy_(false),
45 transport_recv_eof_(false), 45 transport_recv_eof_(false),
46 user_read_buf_len_(0), 46 user_read_buf_len_(0),
47 user_write_buf_len_(0), 47 user_write_buf_len_(0),
48 transport_write_error_(OK), 48 transport_write_error_(OK),
49 ssl_(NULL), 49 ssl_(NULL),
50 transport_bio_(NULL), 50 transport_bio_(NULL),
51 transport_socket_(transport_socket.Pass()), 51 transport_socket_(transport_socket.Pass()),
52 ssl_config_(ssl_config), 52 ssl_config_(ssl_config),
(...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after
611 ResetAndReturn(&user_write_callback_).Run(rv); 611 ResetAndReturn(&user_write_callback_).Run(rv);
612 } 612 }
613 613
614 int SSLServerSocketOpenSSL::Init() { 614 int SSLServerSocketOpenSSL::Init() {
615 DCHECK(!ssl_); 615 DCHECK(!ssl_);
616 DCHECK(!transport_bio_); 616 DCHECK(!transport_bio_);
617 617
618 crypto::OpenSSLErrStackTracer err_tracer(FROM_HERE); 618 crypto::OpenSSLErrStackTracer err_tracer(FROM_HERE);
619 619
620 ScopedSSL_CTX ssl_ctx(SSL_CTX_new(SSLv23_server_method())); 620 ScopedSSL_CTX ssl_ctx(SSL_CTX_new(SSLv23_server_method()));
621
622 if (ssl_config_.require_client_cert)
623 SSL_CTX_set_verify(ssl_ctx.get(), SSL_VERIFY_PEER, NULL);
624
625 ssl_ = SSL_new(ssl_ctx.get()); 621 ssl_ = SSL_new(ssl_ctx.get());
626 if (!ssl_) 622 if (!ssl_)
627 return ERR_UNEXPECTED; 623 return ERR_UNEXPECTED;
628 624
629 BIO* ssl_bio = NULL; 625 BIO* ssl_bio = NULL;
630 // 0 => use default buffer sizes. 626 // 0 => use default buffer sizes.
631 if (!BIO_new_bio_pair(&ssl_bio, 0, &transport_bio_, 0)) 627 if (!BIO_new_bio_pair(&ssl_bio, 0, &transport_bio_, 0))
632 return ERR_UNEXPECTED; 628 return ERR_UNEXPECTED;
633 DCHECK(ssl_bio); 629 DCHECK(ssl_bio);
634 DCHECK(transport_bio_); 630 DCHECK(transport_bio_);
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
682 SSL_clear_options(ssl_, options.clear_mask); 678 SSL_clear_options(ssl_, options.clear_mask);
683 679
684 // Same as above, this time for the SSL mode. 680 // Same as above, this time for the SSL mode.
685 SslSetClearMask mode; 681 SslSetClearMask mode;
686 682
687 mode.ConfigureFlag(SSL_MODE_RELEASE_BUFFERS, true); 683 mode.ConfigureFlag(SSL_MODE_RELEASE_BUFFERS, true);
688 684
689 SSL_set_mode(ssl_, mode.set_mask); 685 SSL_set_mode(ssl_, mode.set_mask);
690 SSL_clear_mode(ssl_, mode.clear_mask); 686 SSL_clear_mode(ssl_, mode.clear_mask);
691 687
692 // See SSLServerConfig::disabled_cipher_suites for description of the suites 688 // See SSLConfig::disabled_cipher_suites for description of the suites
693 // disabled by default. Note that !SHA256 and !SHA384 only remove HMAC-SHA256 689 // disabled by default. Note that !SHA256 and !SHA384 only remove HMAC-SHA256
694 // and HMAC-SHA384 cipher suites, not GCM cipher suites with SHA256 or SHA384 690 // and HMAC-SHA384 cipher suites, not GCM cipher suites with SHA256 or SHA384
695 // as the handshake hash. 691 // as the handshake hash.
696 std::string command("DEFAULT:!SHA256:!SHA384:!AESGCM+AES256:!aPSK"); 692 std::string command("DEFAULT:!SHA256:!SHA384:!AESGCM+AES256:!aPSK");
697 693
698 if (ssl_config_.require_ecdhe) 694 if (ssl_config_.require_ecdhe)
699 command.append(":!kRSA:!kDHE"); 695 command.append(":!kRSA:!kDHE");
700 696
701 // Remove any disabled ciphers. 697 // Remove any disabled ciphers.
702 for (uint16_t id : ssl_config_.disabled_cipher_suites) { 698 for (uint16_t id : ssl_config_.disabled_cipher_suites) {
703 const SSL_CIPHER* cipher = SSL_get_cipher_by_value(id); 699 const SSL_CIPHER* cipher = SSL_get_cipher_by_value(id);
704 if (cipher) { 700 if (cipher) {
705 command.append(":!"); 701 command.append(":!");
706 command.append(SSL_CIPHER_get_name(cipher)); 702 command.append(SSL_CIPHER_get_name(cipher));
707 } 703 }
708 } 704 }
709 705
710 int rv = SSL_set_cipher_list(ssl_, command.c_str()); 706 int rv = SSL_set_cipher_list(ssl_, command.c_str());
711 // If this fails (rv = 0) it means there are no ciphers enabled on this SSL. 707 // If this fails (rv = 0) it means there are no ciphers enabled on this SSL.
712 // This will almost certainly result in the socket failing to complete the 708 // This will almost certainly result in the socket failing to complete the
713 // handshake at which point the appropriate error is bubbled up to the client. 709 // handshake at which point the appropriate error is bubbled up to the client.
714 LOG_IF(WARNING, rv != 1) << "SSL_set_cipher_list('" << command 710 LOG_IF(WARNING, rv != 1) << "SSL_set_cipher_list('" << command
715 << "') returned " << rv; 711 << "') returned " << rv;
716 712
717 return OK; 713 return OK;
718 } 714 }
719 715
720 } // namespace net 716 } // namespace net
OLDNEW
« no previous file with comments | « net/socket/ssl_server_socket_openssl.h ('k') | net/socket/ssl_server_socket_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698