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
3 // found in the LICENSE file.
5 // This test suite uses SSLClientSocket to test the implementation of
6 // SSLServerSocket. In order to establish connections between the sockets
7 // we need two additional classes:
9 // Connects SSL socket to FakeDataChannel. This class is just a stub.
12 // Implements the actual exchange of data between two FakeSockets.
14 // Implementations of these two classes are included in this file.
16 #include "net/socket/ssl_server_socket.h"
22 #include "base/compiler_specific.h"
23 #include "base/files/file_path.h"
24 #include "base/files/file_util.h"
25 #include "base/location.h"
26 #include "base/message_loop/message_loop.h"
27 #include "base/single_thread_task_runner.h"
28 #include "base/thread_task_runner_handle.h"
29 #include "crypto/nss_util.h"
30 #include "crypto/rsa_private_key.h"
31 #include "net/base/address_list.h"
32 #include "net/base/completion_callback.h"
33 #include "net/base/host_port_pair.h"
34 #include "net/base/io_buffer.h"
35 #include "net/base/ip_endpoint.h"
36 #include "net/base/net_errors.h"
37 #include "net/base/test_data_directory.h"
38 #include "net/cert/cert_status_flags.h"
39 #include "net/cert/mock_cert_verifier.h"
40 #include "net/cert/x509_certificate.h"
41 #include "net/http/transport_security_state.h"
42 #include "net/log/net_log.h"
43 #include "net/socket/client_socket_factory.h"
44 #include "net/socket/socket_test_util.h"
45 #include "net/socket/ssl_client_socket.h"
46 #include "net/socket/stream_socket.h"
47 #include "net/ssl/ssl_cipher_suite_names.h"
48 #include "net/ssl/ssl_config_service.h"
49 #include "net/ssl/ssl_connection_status_flags.h"
50 #include "net/ssl/ssl_info.h"
51 #include "net/test/cert_test_util.h"
52 #include "testing/gtest/include/gtest/gtest.h"
53 #include "testing/platform_test.h"
55 #if !defined(USE_OPENSSL)
58 #if !defined(CKM_AES_GCM)
59 #define CKM_AES_GCM 0x00001087
61 #if !defined(CKM_NSS_TLS_MASTER_KEY_DERIVE_DH_SHA256)
62 #define CKM_NSS_TLS_MASTER_KEY_DERIVE_DH_SHA256 (CKM_NSS + 24)
70 class FakeDataChannel
{
75 write_called_after_close_(false),
79 int Read(IOBuffer
* buf
, int buf_len
, const CompletionCallback
& callback
) {
80 DCHECK(read_callback_
.is_null());
81 DCHECK(!read_buf_
.get());
85 read_callback_
= callback
;
87 read_buf_len_
= buf_len
;
88 return ERR_IO_PENDING
;
90 return PropogateData(buf
, buf_len
);
93 int Write(IOBuffer
* buf
, int buf_len
, const CompletionCallback
& callback
) {
94 DCHECK(write_callback_
.is_null());
96 if (write_called_after_close_
)
97 return ERR_CONNECTION_RESET
;
98 write_called_after_close_
= true;
99 write_callback_
= callback
;
100 base::ThreadTaskRunnerHandle::Get()->PostTask(
101 FROM_HERE
, base::Bind(&FakeDataChannel::DoWriteCallback
,
102 weak_factory_
.GetWeakPtr()));
103 return ERR_IO_PENDING
;
105 // This function returns synchronously, so make a copy of the buffer.
106 data_
.push(new DrainableIOBuffer(
107 new StringIOBuffer(std::string(buf
->data(), buf_len
)),
109 base::ThreadTaskRunnerHandle::Get()->PostTask(
110 FROM_HERE
, base::Bind(&FakeDataChannel::DoReadCallback
,
111 weak_factory_
.GetWeakPtr()));
115 // Closes the FakeDataChannel. After Close() is called, Read() returns 0,
116 // indicating EOF, and Write() fails with ERR_CONNECTION_RESET. Note that
117 // after the FakeDataChannel is closed, the first Write() call completes
118 // asynchronously, which is necessary to reproduce bug 127822.
124 void DoReadCallback() {
125 if (read_callback_
.is_null() || data_
.empty())
128 int copied
= PropogateData(read_buf_
, read_buf_len_
);
129 CompletionCallback callback
= read_callback_
;
130 read_callback_
.Reset();
133 callback
.Run(copied
);
136 void DoWriteCallback() {
137 if (write_callback_
.is_null())
140 CompletionCallback callback
= write_callback_
;
141 write_callback_
.Reset();
142 callback
.Run(ERR_CONNECTION_RESET
);
145 int PropogateData(scoped_refptr
<IOBuffer
> read_buf
, int read_buf_len
) {
146 scoped_refptr
<DrainableIOBuffer
> buf
= data_
.front();
147 int copied
= std::min(buf
->BytesRemaining(), read_buf_len
);
148 memcpy(read_buf
->data(), buf
->data(), copied
);
149 buf
->DidConsume(copied
);
151 if (!buf
->BytesRemaining())
156 CompletionCallback read_callback_
;
157 scoped_refptr
<IOBuffer
> read_buf_
;
160 CompletionCallback write_callback_
;
162 std::queue
<scoped_refptr
<DrainableIOBuffer
> > data_
;
164 // True if Close() has been called.
167 // Controls the completion of Write() after the FakeDataChannel is closed.
168 // After the FakeDataChannel is closed, the first Write() call completes
170 bool write_called_after_close_
;
172 base::WeakPtrFactory
<FakeDataChannel
> weak_factory_
;
174 DISALLOW_COPY_AND_ASSIGN(FakeDataChannel
);
177 class FakeSocket
: public StreamSocket
{
179 FakeSocket(FakeDataChannel
* incoming_channel
,
180 FakeDataChannel
* outgoing_channel
)
181 : incoming_(incoming_channel
),
182 outgoing_(outgoing_channel
) {
185 ~FakeSocket() override
{}
187 int Read(IOBuffer
* buf
,
189 const CompletionCallback
& callback
) override
{
190 // Read random number of bytes.
191 buf_len
= rand() % buf_len
+ 1;
192 return incoming_
->Read(buf
, buf_len
, callback
);
195 int Write(IOBuffer
* buf
,
197 const CompletionCallback
& callback
) override
{
198 // Write random number of bytes.
199 buf_len
= rand() % buf_len
+ 1;
200 return outgoing_
->Write(buf
, buf_len
, callback
);
203 int SetReceiveBufferSize(int32 size
) override
{ return OK
; }
205 int SetSendBufferSize(int32 size
) override
{ return OK
; }
207 int Connect(const CompletionCallback
& callback
) override
{ return OK
; }
209 void Disconnect() override
{
214 bool IsConnected() const override
{ return true; }
216 bool IsConnectedAndIdle() const override
{ return true; }
218 int GetPeerAddress(IPEndPoint
* address
) const override
{
219 IPAddressNumber
ip_address(kIPv4AddressSize
);
220 *address
= IPEndPoint(ip_address
, 0 /*port*/);
224 int GetLocalAddress(IPEndPoint
* address
) const override
{
225 IPAddressNumber
ip_address(4);
226 *address
= IPEndPoint(ip_address
, 0);
230 const BoundNetLog
& NetLog() const override
{ return net_log_
; }
232 void SetSubresourceSpeculation() override
{}
233 void SetOmniboxSpeculation() override
{}
235 bool WasEverUsed() const override
{ return true; }
237 bool UsingTCPFastOpen() const override
{ return false; }
239 bool WasNpnNegotiated() const override
{ return false; }
241 NextProto
GetNegotiatedProtocol() const override
{ return kProtoUnknown
; }
243 bool GetSSLInfo(SSLInfo
* ssl_info
) override
{ return false; }
245 void GetConnectionAttempts(ConnectionAttempts
* out
) const override
{
249 void ClearConnectionAttempts() override
{}
251 void AddConnectionAttempts(const ConnectionAttempts
& attempts
) override
{}
254 BoundNetLog net_log_
;
255 FakeDataChannel
* incoming_
;
256 FakeDataChannel
* outgoing_
;
258 DISALLOW_COPY_AND_ASSIGN(FakeSocket
);
263 // Verify the correctness of the test helper classes first.
264 TEST(FakeSocketTest
, DataTransfer
) {
265 // Establish channels between two sockets.
266 FakeDataChannel channel_1
;
267 FakeDataChannel channel_2
;
268 FakeSocket
client(&channel_1
, &channel_2
);
269 FakeSocket
server(&channel_2
, &channel_1
);
271 const char kTestData
[] = "testing123";
272 const int kTestDataSize
= strlen(kTestData
);
273 const int kReadBufSize
= 1024;
274 scoped_refptr
<IOBuffer
> write_buf
= new StringIOBuffer(kTestData
);
275 scoped_refptr
<IOBuffer
> read_buf
= new IOBuffer(kReadBufSize
);
279 server
.Write(write_buf
.get(), kTestDataSize
, CompletionCallback());
280 EXPECT_GT(written
, 0);
281 EXPECT_LE(written
, kTestDataSize
);
283 int read
= client
.Read(read_buf
.get(), kReadBufSize
, CompletionCallback());
285 EXPECT_LE(read
, written
);
286 EXPECT_EQ(0, memcmp(kTestData
, read_buf
->data(), read
));
289 TestCompletionCallback callback
;
290 EXPECT_EQ(ERR_IO_PENDING
,
291 server
.Read(read_buf
.get(), kReadBufSize
, callback
.callback()));
293 written
= client
.Write(write_buf
.get(), kTestDataSize
, CompletionCallback());
294 EXPECT_GT(written
, 0);
295 EXPECT_LE(written
, kTestDataSize
);
297 read
= callback
.WaitForResult();
299 EXPECT_LE(read
, written
);
300 EXPECT_EQ(0, memcmp(kTestData
, read_buf
->data(), read
));
303 class SSLServerSocketTest
: public PlatformTest
{
305 SSLServerSocketTest()
306 : socket_factory_(ClientSocketFactory::GetDefaultFactory()),
307 cert_verifier_(new MockCertVerifier()),
308 transport_security_state_(new TransportSecurityState
) {
309 cert_verifier_
->set_default_result(CERT_STATUS_AUTHORITY_INVALID
);
314 scoped_ptr
<ClientSocketHandle
> client_connection(new ClientSocketHandle
);
315 client_connection
->SetSocket(
316 scoped_ptr
<StreamSocket
>(new FakeSocket(&channel_1_
, &channel_2_
)));
317 scoped_ptr
<StreamSocket
> server_socket(
318 new FakeSocket(&channel_2_
, &channel_1_
));
320 base::FilePath
certs_dir(GetTestCertsDirectory());
322 base::FilePath cert_path
= certs_dir
.AppendASCII("unittest.selfsigned.der");
323 std::string cert_der
;
324 ASSERT_TRUE(base::ReadFileToString(cert_path
, &cert_der
));
326 scoped_refptr
<X509Certificate
> cert
=
327 X509Certificate::CreateFromBytes(cert_der
.data(), cert_der
.size());
329 base::FilePath key_path
= certs_dir
.AppendASCII("unittest.key.bin");
330 std::string key_string
;
331 ASSERT_TRUE(base::ReadFileToString(key_path
, &key_string
));
332 std::vector
<uint8
> key_vector(
333 reinterpret_cast<const uint8
*>(key_string
.data()),
334 reinterpret_cast<const uint8
*>(key_string
.data() +
335 key_string
.length()));
337 scoped_ptr
<crypto::RSAPrivateKey
> private_key(
338 crypto::RSAPrivateKey::CreateFromPrivateKeyInfo(key_vector
));
340 client_ssl_config_
.false_start_enabled
= false;
341 client_ssl_config_
.channel_id_enabled
= false;
343 // Certificate provided by the host doesn't need authority.
344 SSLConfig::CertAndStatus cert_and_status
;
345 cert_and_status
.cert_status
= CERT_STATUS_AUTHORITY_INVALID
;
346 cert_and_status
.der_cert
= cert_der
;
347 client_ssl_config_
.allowed_bad_certs
.push_back(cert_and_status
);
349 HostPortPair
host_and_pair("unittest", 0);
350 SSLClientSocketContext context
;
351 context
.cert_verifier
= cert_verifier_
.get();
352 context
.transport_security_state
= transport_security_state_
.get();
353 client_socket_
= socket_factory_
->CreateSSLClientSocket(
354 client_connection
.Pass(), host_and_pair
, client_ssl_config_
, context
);
356 CreateSSLServerSocket(server_socket
.Pass(), cert
.get(),
357 private_key
.get(), server_ssl_config_
);
360 FakeDataChannel channel_1_
;
361 FakeDataChannel channel_2_
;
362 SSLConfig client_ssl_config_
;
363 SSLConfig server_ssl_config_
;
364 scoped_ptr
<SSLClientSocket
> client_socket_
;
365 scoped_ptr
<SSLServerSocket
> server_socket_
;
366 ClientSocketFactory
* socket_factory_
;
367 scoped_ptr
<MockCertVerifier
> cert_verifier_
;
368 scoped_ptr
<TransportSecurityState
> transport_security_state_
;
371 // This test only executes creation of client and server sockets. This is to
372 // test that creation of sockets doesn't crash and have minimal code to run
373 // under valgrind in order to help debugging memory problems.
374 TEST_F(SSLServerSocketTest
, Initialize
) {
378 // This test executes Connect() on SSLClientSocket and Handshake() on
379 // SSLServerSocket to make sure handshaking between the two sockets is
380 // completed successfully.
381 TEST_F(SSLServerSocketTest
, Handshake
) {
384 TestCompletionCallback connect_callback
;
385 TestCompletionCallback handshake_callback
;
387 int server_ret
= server_socket_
->Handshake(handshake_callback
.callback());
388 EXPECT_TRUE(server_ret
== OK
|| server_ret
== ERR_IO_PENDING
);
390 int client_ret
= client_socket_
->Connect(connect_callback
.callback());
391 EXPECT_TRUE(client_ret
== OK
|| client_ret
== ERR_IO_PENDING
);
393 if (client_ret
== ERR_IO_PENDING
) {
394 EXPECT_EQ(OK
, connect_callback
.WaitForResult());
396 if (server_ret
== ERR_IO_PENDING
) {
397 EXPECT_EQ(OK
, handshake_callback
.WaitForResult());
400 // Make sure the cert status is expected.
402 ASSERT_TRUE(client_socket_
->GetSSLInfo(&ssl_info
));
403 EXPECT_EQ(CERT_STATUS_AUTHORITY_INVALID
, ssl_info
.cert_status
);
405 // The default cipher suite should be ECDHE and, unless on NSS and the
406 // platform doesn't support it, an AEAD.
407 uint16_t cipher_suite
=
408 SSLConnectionStatusToCipherSuite(ssl_info
.connection_status
);
409 const char* key_exchange
;
413 SSLCipherSuiteToStrings(&key_exchange
, &cipher
, &mac
, &is_aead
, cipher_suite
);
414 EXPECT_STREQ("ECDHE_RSA", key_exchange
);
415 #if defined(USE_OPENSSL)
416 bool supports_aead
= true;
419 PK11_TokenExists(CKM_AES_GCM
) &&
420 PK11_TokenExists(CKM_NSS_TLS_MASTER_KEY_DERIVE_DH_SHA256
);
422 EXPECT_TRUE(!supports_aead
|| is_aead
);
425 TEST_F(SSLServerSocketTest
, DataTransfer
) {
428 TestCompletionCallback connect_callback
;
429 TestCompletionCallback handshake_callback
;
431 // Establish connection.
432 int client_ret
= client_socket_
->Connect(connect_callback
.callback());
433 ASSERT_TRUE(client_ret
== OK
|| client_ret
== ERR_IO_PENDING
);
435 int server_ret
= server_socket_
->Handshake(handshake_callback
.callback());
436 ASSERT_TRUE(server_ret
== OK
|| server_ret
== ERR_IO_PENDING
);
438 client_ret
= connect_callback
.GetResult(client_ret
);
439 ASSERT_EQ(OK
, client_ret
);
440 server_ret
= handshake_callback
.GetResult(server_ret
);
441 ASSERT_EQ(OK
, server_ret
);
443 const int kReadBufSize
= 1024;
444 scoped_refptr
<StringIOBuffer
> write_buf
=
445 new StringIOBuffer("testing123");
446 scoped_refptr
<DrainableIOBuffer
> read_buf
=
447 new DrainableIOBuffer(new IOBuffer(kReadBufSize
), kReadBufSize
);
450 TestCompletionCallback write_callback
;
451 TestCompletionCallback read_callback
;
452 server_ret
= server_socket_
->Write(
453 write_buf
.get(), write_buf
->size(), write_callback
.callback());
454 EXPECT_TRUE(server_ret
> 0 || server_ret
== ERR_IO_PENDING
);
455 client_ret
= client_socket_
->Read(
456 read_buf
.get(), read_buf
->BytesRemaining(), read_callback
.callback());
457 EXPECT_TRUE(client_ret
> 0 || client_ret
== ERR_IO_PENDING
);
459 server_ret
= write_callback
.GetResult(server_ret
);
460 EXPECT_GT(server_ret
, 0);
461 client_ret
= read_callback
.GetResult(client_ret
);
462 ASSERT_GT(client_ret
, 0);
464 read_buf
->DidConsume(client_ret
);
465 while (read_buf
->BytesConsumed() < write_buf
->size()) {
466 client_ret
= client_socket_
->Read(
467 read_buf
.get(), read_buf
->BytesRemaining(), read_callback
.callback());
468 EXPECT_TRUE(client_ret
> 0 || client_ret
== ERR_IO_PENDING
);
469 client_ret
= read_callback
.GetResult(client_ret
);
470 ASSERT_GT(client_ret
, 0);
471 read_buf
->DidConsume(client_ret
);
473 EXPECT_EQ(write_buf
->size(), read_buf
->BytesConsumed());
474 read_buf
->SetOffset(0);
475 EXPECT_EQ(0, memcmp(write_buf
->data(), read_buf
->data(), write_buf
->size()));
478 write_buf
= new StringIOBuffer("hello123");
479 server_ret
= server_socket_
->Read(
480 read_buf
.get(), read_buf
->BytesRemaining(), read_callback
.callback());
481 EXPECT_TRUE(server_ret
> 0 || server_ret
== ERR_IO_PENDING
);
482 client_ret
= client_socket_
->Write(
483 write_buf
.get(), write_buf
->size(), write_callback
.callback());
484 EXPECT_TRUE(client_ret
> 0 || client_ret
== ERR_IO_PENDING
);
486 server_ret
= read_callback
.GetResult(server_ret
);
487 ASSERT_GT(server_ret
, 0);
488 client_ret
= write_callback
.GetResult(client_ret
);
489 EXPECT_GT(client_ret
, 0);
491 read_buf
->DidConsume(server_ret
);
492 while (read_buf
->BytesConsumed() < write_buf
->size()) {
493 server_ret
= server_socket_
->Read(
494 read_buf
.get(), read_buf
->BytesRemaining(), read_callback
.callback());
495 EXPECT_TRUE(server_ret
> 0 || server_ret
== ERR_IO_PENDING
);
496 server_ret
= read_callback
.GetResult(server_ret
);
497 ASSERT_GT(server_ret
, 0);
498 read_buf
->DidConsume(server_ret
);
500 EXPECT_EQ(write_buf
->size(), read_buf
->BytesConsumed());
501 read_buf
->SetOffset(0);
502 EXPECT_EQ(0, memcmp(write_buf
->data(), read_buf
->data(), write_buf
->size()));
505 // A regression test for bug 127822 (http://crbug.com/127822).
506 // If the server closes the connection after the handshake is finished,
507 // the client's Write() call should not cause an infinite loop.
508 // NOTE: this is a test for SSLClientSocket rather than SSLServerSocket.
509 TEST_F(SSLServerSocketTest
, ClientWriteAfterServerClose
) {
512 TestCompletionCallback connect_callback
;
513 TestCompletionCallback handshake_callback
;
515 // Establish connection.
516 int client_ret
= client_socket_
->Connect(connect_callback
.callback());
517 ASSERT_TRUE(client_ret
== OK
|| client_ret
== ERR_IO_PENDING
);
519 int server_ret
= server_socket_
->Handshake(handshake_callback
.callback());
520 ASSERT_TRUE(server_ret
== OK
|| server_ret
== ERR_IO_PENDING
);
522 client_ret
= connect_callback
.GetResult(client_ret
);
523 ASSERT_EQ(OK
, client_ret
);
524 server_ret
= handshake_callback
.GetResult(server_ret
);
525 ASSERT_EQ(OK
, server_ret
);
527 scoped_refptr
<StringIOBuffer
> write_buf
= new StringIOBuffer("testing123");
529 // The server closes the connection. The server needs to write some
530 // data first so that the client's Read() calls from the transport
531 // socket won't return ERR_IO_PENDING. This ensures that the client
532 // will call Read() on the transport socket again.
533 TestCompletionCallback write_callback
;
535 server_ret
= server_socket_
->Write(
536 write_buf
.get(), write_buf
->size(), write_callback
.callback());
537 EXPECT_TRUE(server_ret
> 0 || server_ret
== ERR_IO_PENDING
);
539 server_ret
= write_callback
.GetResult(server_ret
);
540 EXPECT_GT(server_ret
, 0);
542 server_socket_
->Disconnect();
544 // The client writes some data. This should not cause an infinite loop.
545 client_ret
= client_socket_
->Write(
546 write_buf
.get(), write_buf
->size(), write_callback
.callback());
547 EXPECT_TRUE(client_ret
> 0 || client_ret
== ERR_IO_PENDING
);
549 client_ret
= write_callback
.GetResult(client_ret
);
550 EXPECT_GT(client_ret
, 0);
552 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
553 FROM_HERE
, base::MessageLoop::QuitClosure(),
554 base::TimeDelta::FromMilliseconds(10));
555 base::MessageLoop::current()->Run();
558 // This test executes ExportKeyingMaterial() on the client and server sockets,
559 // after connecting them, and verifies that the results match.
560 // This test will fail if False Start is enabled (see crbug.com/90208).
561 TEST_F(SSLServerSocketTest
, ExportKeyingMaterial
) {
564 TestCompletionCallback connect_callback
;
565 TestCompletionCallback handshake_callback
;
567 int client_ret
= client_socket_
->Connect(connect_callback
.callback());
568 ASSERT_TRUE(client_ret
== OK
|| client_ret
== ERR_IO_PENDING
);
570 int server_ret
= server_socket_
->Handshake(handshake_callback
.callback());
571 ASSERT_TRUE(server_ret
== OK
|| server_ret
== ERR_IO_PENDING
);
573 if (client_ret
== ERR_IO_PENDING
) {
574 ASSERT_EQ(OK
, connect_callback
.WaitForResult());
576 if (server_ret
== ERR_IO_PENDING
) {
577 ASSERT_EQ(OK
, handshake_callback
.WaitForResult());
580 const int kKeyingMaterialSize
= 32;
581 const char kKeyingLabel
[] = "EXPERIMENTAL-server-socket-test";
582 const char kKeyingContext
[] = "";
583 unsigned char server_out
[kKeyingMaterialSize
];
584 int rv
= server_socket_
->ExportKeyingMaterial(kKeyingLabel
,
585 false, kKeyingContext
,
586 server_out
, sizeof(server_out
));
589 unsigned char client_out
[kKeyingMaterialSize
];
590 rv
= client_socket_
->ExportKeyingMaterial(kKeyingLabel
,
591 false, kKeyingContext
,
592 client_out
, sizeof(client_out
));
594 EXPECT_EQ(0, memcmp(server_out
, client_out
, sizeof(server_out
)));
596 const char kKeyingLabelBad
[] = "EXPERIMENTAL-server-socket-test-bad";
597 unsigned char client_bad
[kKeyingMaterialSize
];
598 rv
= client_socket_
->ExportKeyingMaterial(kKeyingLabelBad
,
599 false, kKeyingContext
,
600 client_bad
, sizeof(client_bad
));
602 EXPECT_NE(0, memcmp(server_out
, client_bad
, sizeof(server_out
)));
605 // Verifies that SSLConfig::require_ecdhe flags works properly.
606 TEST_F(SSLServerSocketTest
, RequireEcdheFlag
) {
607 // Disable all ECDHE suites on the client side.
608 uint16_t kEcdheCiphers
[] = {
609 0xc007, // ECDHE_ECDSA_WITH_RC4_128_SHA
610 0xc009, // ECDHE_ECDSA_WITH_AES_128_CBC_SHA
611 0xc00a, // ECDHE_ECDSA_WITH_AES_256_CBC_SHA
612 0xc011, // ECDHE_RSA_WITH_RC4_128_SHA
613 0xc013, // ECDHE_RSA_WITH_AES_128_CBC_SHA
614 0xc014, // ECDHE_RSA_WITH_AES_256_CBC_SHA
615 0xc02b, // ECDHE_ECDSA_WITH_AES_128_GCM_SHA256
616 0xc02f, // ECDHE_RSA_WITH_AES_128_GCM_SHA256
617 0xcc13, // ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256
618 0xcc14, // ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256
620 client_ssl_config_
.disabled_cipher_suites
.assign(
621 kEcdheCiphers
, kEcdheCiphers
+ arraysize(kEcdheCiphers
));
623 // Require ECDHE on the server.
624 server_ssl_config_
.require_ecdhe
= true;
628 TestCompletionCallback connect_callback
;
629 TestCompletionCallback handshake_callback
;
631 int client_ret
= client_socket_
->Connect(connect_callback
.callback());
632 int server_ret
= server_socket_
->Handshake(handshake_callback
.callback());
634 client_ret
= connect_callback
.GetResult(client_ret
);
635 server_ret
= handshake_callback
.GetResult(server_ret
);
637 ASSERT_EQ(ERR_SSL_VERSION_OR_CIPHER_MISMATCH
, client_ret
);
638 ASSERT_EQ(ERR_SSL_VERSION_OR_CIPHER_MISMATCH
, server_ret
);