Index: net/socket/ssl_client_socket_unittest.cc |
diff --git a/net/socket/ssl_client_socket_unittest.cc b/net/socket/ssl_client_socket_unittest.cc |
index d151cfbf18b25939085a2a0bf2f1f0f3ad179724..bf029be2755e4446c6184ecd8a76ccb2b5b07ebf 100644 |
--- a/net/socket/ssl_client_socket_unittest.cc |
+++ b/net/socket/ssl_client_socket_unittest.cc |
@@ -3131,6 +3131,10 @@ TEST_F(SSLClientSocketTest, RequireECDHE) { |
EXPECT_EQ(ERR_SSL_VERSION_OR_CIPHER_MISMATCH, rv); |
} |
+// In tests requiring NPN, client_config.alpn_protos and |
+// client_config.npn_protos both need to be set when using NSS, otherwise NPN is |
+// disabled due to quirks of the implementation. |
+ |
TEST_F(SSLClientSocketFalseStartTest, FalseStartEnabled) { |
// False Start requires NPN/ALPN, ECDHE, and an AEAD. |
SpawnedTestServer::SSLOptions server_options; |
@@ -3140,7 +3144,10 @@ TEST_F(SSLClientSocketFalseStartTest, FalseStartEnabled) { |
SpawnedTestServer::SSLOptions::BULK_CIPHER_AES128GCM; |
server_options.npn_protocols.push_back(std::string("http/1.1")); |
SSLConfig client_config; |
- client_config.next_protos.push_back(kProtoHTTP11); |
+#if !defined(USE_OPENSSL) |
+ client_config.alpn_protos.push_back(kProtoHTTP11); |
+#endif |
+ client_config.npn_protos.push_back(kProtoHTTP11); |
ASSERT_NO_FATAL_FAILURE( |
TestFalseStart(server_options, client_config, true)); |
} |
@@ -3153,7 +3160,8 @@ TEST_F(SSLClientSocketFalseStartTest, NoNPN) { |
server_options.bulk_ciphers = |
SpawnedTestServer::SSLOptions::BULK_CIPHER_AES128GCM; |
SSLConfig client_config; |
- client_config.next_protos.clear(); |
+ client_config.alpn_protos.clear(); |
+ client_config.npn_protos.clear(); |
ASSERT_NO_FATAL_FAILURE( |
TestFalseStart(server_options, client_config, false)); |
} |
@@ -3167,7 +3175,10 @@ TEST_F(SSLClientSocketFalseStartTest, RSA) { |
SpawnedTestServer::SSLOptions::BULK_CIPHER_AES128GCM; |
server_options.npn_protocols.push_back(std::string("http/1.1")); |
SSLConfig client_config; |
- client_config.next_protos.push_back(kProtoHTTP11); |
+#if !defined(USE_OPENSSL) |
+ client_config.alpn_protos.push_back(kProtoHTTP11); |
+#endif |
+ client_config.npn_protos.push_back(kProtoHTTP11); |
ASSERT_NO_FATAL_FAILURE( |
TestFalseStart(server_options, client_config, false)); |
} |
@@ -3181,7 +3192,10 @@ TEST_F(SSLClientSocketFalseStartTest, DHE_RSA) { |
SpawnedTestServer::SSLOptions::BULK_CIPHER_AES128GCM; |
server_options.npn_protocols.push_back(std::string("http/1.1")); |
SSLConfig client_config; |
- client_config.next_protos.push_back(kProtoHTTP11); |
+#if !defined(USE_OPENSSL) |
+ client_config.alpn_protos.push_back(kProtoHTTP11); |
+#endif |
+ client_config.npn_protos.push_back(kProtoHTTP11); |
ASSERT_NO_FATAL_FAILURE(TestFalseStart(server_options, client_config, false)); |
} |
@@ -3194,7 +3208,10 @@ TEST_F(SSLClientSocketFalseStartTest, NoAEAD) { |
SpawnedTestServer::SSLOptions::BULK_CIPHER_AES128; |
server_options.npn_protocols.push_back(std::string("http/1.1")); |
SSLConfig client_config; |
- client_config.next_protos.push_back(kProtoHTTP11); |
+#if !defined(USE_OPENSSL) |
+ client_config.alpn_protos.push_back(kProtoHTTP11); |
+#endif |
+ client_config.npn_protos.push_back(kProtoHTTP11); |
ASSERT_NO_FATAL_FAILURE(TestFalseStart(server_options, client_config, false)); |
} |
@@ -3208,7 +3225,10 @@ TEST_F(SSLClientSocketFalseStartTest, SessionResumption) { |
SpawnedTestServer::SSLOptions::BULK_CIPHER_AES128GCM; |
server_options.npn_protocols.push_back(std::string("http/1.1")); |
SSLConfig client_config; |
- client_config.next_protos.push_back(kProtoHTTP11); |
+#if !defined(USE_OPENSSL) |
+ client_config.alpn_protos.push_back(kProtoHTTP11); |
+#endif |
+ client_config.npn_protos.push_back(kProtoHTTP11); |
// Let a full handshake complete with False Start. |
ASSERT_NO_FATAL_FAILURE( |
@@ -3243,7 +3263,10 @@ TEST_F(SSLClientSocketFalseStartTest, NoSessionResumptionBeforeFinished) { |
ASSERT_TRUE(StartTestServer(server_options)); |
SSLConfig client_config; |
- client_config.next_protos.push_back(kProtoHTTP11); |
+#if !defined(USE_OPENSSL) |
+ client_config.alpn_protos.push_back(kProtoHTTP11); |
+#endif |
+ client_config.npn_protos.push_back(kProtoHTTP11); |
// Start a handshake up to the server Finished message. |
TestCompletionCallback callback; |
@@ -3301,7 +3324,10 @@ TEST_F(SSLClientSocketFalseStartTest, NoSessionResumptionBadFinished) { |
ASSERT_TRUE(StartTestServer(server_options)); |
SSLConfig client_config; |
- client_config.next_protos.push_back(kProtoHTTP11); |
+#if !defined(USE_OPENSSL) |
+ client_config.alpn_protos.push_back(kProtoHTTP11); |
+#endif |
+ client_config.npn_protos.push_back(kProtoHTTP11); |
// Start a handshake up to the server Finished message. |
TestCompletionCallback callback; |
@@ -3425,8 +3451,12 @@ TEST_F(SSLClientSocketTest, NPN) { |
ASSERT_TRUE(ConnectToTestServer(server_options)); |
SSLConfig client_config; |
- client_config.next_protos.push_back(kProtoHTTP2); |
- client_config.next_protos.push_back(kProtoHTTP11); |
+#if !defined(USE_OPENSSL) |
+ client_config.alpn_protos.push_back(kProtoHTTP2); |
+ client_config.alpn_protos.push_back(kProtoHTTP11); |
+#endif |
+ client_config.npn_protos.push_back(kProtoHTTP2); |
+ client_config.npn_protos.push_back(kProtoHTTP11); |
int rv; |
ASSERT_TRUE(CreateAndConnectSSLClientSocket(client_config, &rv)); |
@@ -3445,8 +3475,12 @@ TEST_F(SSLClientSocketTest, NPNNoOverlap) { |
ASSERT_TRUE(ConnectToTestServer(server_options)); |
SSLConfig client_config; |
- client_config.next_protos.push_back(kProtoSPDY31); |
- client_config.next_protos.push_back(kProtoHTTP2); |
+#if !defined(USE_OPENSSL) |
+ client_config.alpn_protos.push_back(kProtoSPDY31); |
+ client_config.alpn_protos.push_back(kProtoHTTP2); |
+#endif |
+ client_config.npn_protos.push_back(kProtoSPDY31); |
+ client_config.npn_protos.push_back(kProtoHTTP2); |
int rv; |
ASSERT_TRUE(CreateAndConnectSSLClientSocket(client_config, &rv)); |
@@ -3466,8 +3500,12 @@ TEST_F(SSLClientSocketTest, NPNServerPreference) { |
ASSERT_TRUE(ConnectToTestServer(server_options)); |
SSLConfig client_config; |
- client_config.next_protos.push_back(kProtoHTTP2); |
- client_config.next_protos.push_back(kProtoSPDY31); |
+#if !defined(USE_OPENSSL) |
+ client_config.alpn_protos.push_back(kProtoHTTP2); |
+ client_config.alpn_protos.push_back(kProtoSPDY31); |
+#endif |
+ client_config.npn_protos.push_back(kProtoHTTP2); |
+ client_config.npn_protos.push_back(kProtoSPDY31); |
int rv; |
ASSERT_TRUE(CreateAndConnectSSLClientSocket(client_config, &rv)); |
@@ -3499,7 +3537,10 @@ TEST_F(SSLClientSocketTest, NPNServerDisabled) { |
ASSERT_TRUE(ConnectToTestServer(server_options)); |
SSLConfig client_config; |
- client_config.next_protos.push_back(kProtoHTTP11); |
+#if !defined(USE_OPENSSL) |
+ client_config.alpn_protos.push_back(kProtoHTTP11); |
+#endif |
+ client_config.npn_protos.push_back(kProtoHTTP11); |
int rv; |
ASSERT_TRUE(CreateAndConnectSSLClientSocket(client_config, &rv)); |