| OLD | NEW |
| 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_nss.h" | 5 #include "net/socket/ssl_server_socket_nss.h" |
| 6 | 6 |
| 7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
| 8 #include <winsock2.h> | 8 #include <winsock2.h> |
| 9 #endif | 9 #endif |
| 10 | 10 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 #include <limits> | 30 #include <limits> |
| 31 | 31 |
| 32 #include "base/memory/ref_counted.h" | 32 #include "base/memory/ref_counted.h" |
| 33 #include "crypto/rsa_private_key.h" | 33 #include "crypto/rsa_private_key.h" |
| 34 #include "crypto/nss_util_internal.h" | 34 #include "crypto/nss_util_internal.h" |
| 35 #include "net/base/io_buffer.h" | 35 #include "net/base/io_buffer.h" |
| 36 #include "net/base/net_errors.h" | 36 #include "net/base/net_errors.h" |
| 37 #include "net/base/net_log.h" | 37 #include "net/base/net_log.h" |
| 38 #include "net/ocsp/nss_ocsp.h" | 38 #include "net/ocsp/nss_ocsp.h" |
| 39 #include "net/socket/nss_ssl_util.h" | 39 #include "net/socket/nss_ssl_util.h" |
| 40 #include "net/socket/nss_ssl_util_internal.h" |
| 40 #include "net/socket/ssl_error_params.h" | 41 #include "net/socket/ssl_error_params.h" |
| 41 | 42 |
| 42 static const int kRecvBufferSize = 4096; | 43 static const int kRecvBufferSize = 4096; |
| 43 | 44 |
| 44 #define GotoState(s) next_handshake_state_ = s | 45 #define GotoState(s) next_handshake_state_ = s |
| 45 | 46 |
| 46 namespace net { | 47 namespace net { |
| 47 | 48 |
| 48 SSLServerSocket* CreateSSLServerSocket( | 49 SSLServerSocket* CreateSSLServerSocket( |
| 49 StreamSocket* socket, | 50 StreamSocket* socket, |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 LogFailedNSSFunction(net_log_, "SSL_OptionSet", "SSL_REQUEST_CERTIFICATE"); | 329 LogFailedNSSFunction(net_log_, "SSL_OptionSet", "SSL_REQUEST_CERTIFICATE"); |
| 329 return ERR_UNEXPECTED; | 330 return ERR_UNEXPECTED; |
| 330 } | 331 } |
| 331 | 332 |
| 332 rv = SSL_OptionSet(nss_fd_, SSL_REQUIRE_CERTIFICATE, PR_FALSE); | 333 rv = SSL_OptionSet(nss_fd_, SSL_REQUIRE_CERTIFICATE, PR_FALSE); |
| 333 if (rv != SECSuccess) { | 334 if (rv != SECSuccess) { |
| 334 LogFailedNSSFunction(net_log_, "SSL_OptionSet", "SSL_REQUIRE_CERTIFICATE"); | 335 LogFailedNSSFunction(net_log_, "SSL_OptionSet", "SSL_REQUIRE_CERTIFICATE"); |
| 335 return ERR_UNEXPECTED; | 336 return ERR_UNEXPECTED; |
| 336 } | 337 } |
| 337 | 338 |
| 338 rv = SSL_ConfigServerSessionIDCache(1024, 5, 5, NULL); | |
| 339 if (rv != SECSuccess) { | |
| 340 LogFailedNSSFunction(net_log_, "SSL_ConfigureServerSessionIDCache", ""); | |
| 341 return ERR_UNEXPECTED; | |
| 342 } | |
| 343 | |
| 344 rv = SSL_AuthCertificateHook(nss_fd_, OwnAuthCertHandler, this); | 339 rv = SSL_AuthCertificateHook(nss_fd_, OwnAuthCertHandler, this); |
| 345 if (rv != SECSuccess) { | 340 if (rv != SECSuccess) { |
| 346 LogFailedNSSFunction(net_log_, "SSL_AuthCertificateHook", ""); | 341 LogFailedNSSFunction(net_log_, "SSL_AuthCertificateHook", ""); |
| 347 return ERR_UNEXPECTED; | 342 return ERR_UNEXPECTED; |
| 348 } | 343 } |
| 349 | 344 |
| 350 rv = SSL_HandshakeCallback(nss_fd_, HandshakeCallback, this); | 345 rv = SSL_HandshakeCallback(nss_fd_, HandshakeCallback, this); |
| 351 if (rv != SECSuccess) { | 346 if (rv != SECSuccess) { |
| 352 LogFailedNSSFunction(net_log_, "SSL_HandshakeCallback", ""); | 347 LogFailedNSSFunction(net_log_, "SSL_HandshakeCallback", ""); |
| 353 return ERR_UNEXPECTED; | 348 return ERR_UNEXPECTED; |
| (...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 764 // TODO(hclam): Implement. | 759 // TODO(hclam): Implement. |
| 765 } | 760 } |
| 766 | 761 |
| 767 int SSLServerSocketNSS::Init() { | 762 int SSLServerSocketNSS::Init() { |
| 768 // Initialize the NSS SSL library in a threadsafe way. This also | 763 // Initialize the NSS SSL library in a threadsafe way. This also |
| 769 // initializes the NSS base library. | 764 // initializes the NSS base library. |
| 770 EnsureNSSSSLInit(); | 765 EnsureNSSSSLInit(); |
| 771 if (!NSS_IsInitialized()) | 766 if (!NSS_IsInitialized()) |
| 772 return ERR_UNEXPECTED; | 767 return ERR_UNEXPECTED; |
| 773 | 768 |
| 769 EnsureNSSSSLServerInit(); |
| 774 return OK; | 770 return OK; |
| 775 } | 771 } |
| 776 | 772 |
| 777 } // namespace net | 773 } // namespace net |
| OLD | NEW |