|
|
cae166 |
# HG changeset patch
|
|
|
cae166 |
# User Daiki Ueno <dueno@redhat.com>
|
|
|
cae166 |
# Date 1559121620 -7200
|
|
|
cae166 |
# Wed May 29 11:20:20 2019 +0200
|
|
|
cae166 |
# Node ID 29a48b604602a523defd6f9322a5adeca7e284a5
|
|
|
cae166 |
# Parent 43a7fb4f994a31222c308113b0fccdd5480d5b8e
|
|
|
cae166 |
Bug 1553443, send session ticket only after handshake is marked as finished
|
|
|
cae166 |
|
|
|
cae166 |
Reviewers: mt
|
|
|
cae166 |
|
|
|
cae166 |
Reviewed By: mt
|
|
|
cae166 |
|
|
|
cae166 |
Bug #: 1553443
|
|
|
cae166 |
|
|
|
cae166 |
Differential Revision: https://phabricator.services.mozilla.com/D32128
|
|
|
cae166 |
|
|
|
cae166 |
diff --git a/gtests/ssl_gtest/ssl_auth_unittest.cc b/gtests/ssl_gtest/ssl_auth_unittest.cc
|
|
|
cae166 |
--- a/gtests/ssl_gtest/ssl_auth_unittest.cc
|
|
|
cae166 |
+++ b/gtests/ssl_gtest/ssl_auth_unittest.cc
|
|
|
cae166 |
@@ -537,6 +537,40 @@ TEST_F(TlsConnectStreamTls13, PostHandsh
|
|
|
cae166 |
capture_cert_req->buffer().len()));
|
|
|
cae166 |
}
|
|
|
cae166 |
|
|
|
cae166 |
+// Check if post-handshake auth still works when session tickets are enabled:
|
|
|
cae166 |
+// https://bugzilla.mozilla.org/show_bug.cgi?id=1553443
|
|
|
cae166 |
+TEST_F(TlsConnectStreamTls13, PostHandshakeAuthWithSessionTicketsEnabled) {
|
|
|
cae166 |
+ EnsureTlsSetup();
|
|
|
cae166 |
+ client_->SetupClientAuth();
|
|
|
cae166 |
+ EXPECT_EQ(SECSuccess, SSL_OptionSet(client_->ssl_fd(),
|
|
|
cae166 |
+ SSL_ENABLE_POST_HANDSHAKE_AUTH, PR_TRUE));
|
|
|
cae166 |
+ EXPECT_EQ(SECSuccess, SSL_OptionSet(client_->ssl_fd(),
|
|
|
cae166 |
+ SSL_ENABLE_SESSION_TICKETS, PR_TRUE));
|
|
|
cae166 |
+ EXPECT_EQ(SECSuccess, SSL_OptionSet(server_->ssl_fd(),
|
|
|
cae166 |
+ SSL_ENABLE_SESSION_TICKETS, PR_TRUE));
|
|
|
cae166 |
+ size_t called = 0;
|
|
|
cae166 |
+ server_->SetAuthCertificateCallback(
|
|
|
cae166 |
+ [&called](TlsAgent*, PRBool, PRBool) -> SECStatus {
|
|
|
cae166 |
+ called++;
|
|
|
cae166 |
+ return SECSuccess;
|
|
|
cae166 |
+ });
|
|
|
cae166 |
+ Connect();
|
|
|
cae166 |
+ EXPECT_EQ(0U, called);
|
|
|
cae166 |
+ // Send CertificateRequest.
|
|
|
cae166 |
+ EXPECT_EQ(SECSuccess, SSL_GetClientAuthDataHook(
|
|
|
cae166 |
+ client_->ssl_fd(), GetClientAuthDataHook, nullptr));
|
|
|
cae166 |
+ EXPECT_EQ(SECSuccess, SSL_SendCertificateRequest(server_->ssl_fd()))
|
|
|
cae166 |
+ << "Unexpected error: " << PORT_ErrorToName(PORT_GetError());
|
|
|
cae166 |
+ server_->SendData(50);
|
|
|
cae166 |
+ client_->ReadBytes(50);
|
|
|
cae166 |
+ client_->SendData(50);
|
|
|
cae166 |
+ server_->ReadBytes(50);
|
|
|
cae166 |
+ EXPECT_EQ(1U, called);
|
|
|
cae166 |
+ ScopedCERTCertificate cert1(SSL_PeerCertificate(server_->ssl_fd()));
|
|
|
cae166 |
+ ScopedCERTCertificate cert2(SSL_LocalCertificate(client_->ssl_fd()));
|
|
|
cae166 |
+ EXPECT_TRUE(SECITEM_ItemsAreEqual(&cert1->derCert, &cert2->derCert));
|
|
|
cae166 |
+}
|
|
|
cae166 |
+
|
|
|
cae166 |
// In TLS 1.3, the client sends its cert rejection on the
|
|
|
cae166 |
// second flight, and since it has already received the
|
|
|
cae166 |
// server's Finished, it transitions to complete and
|
|
|
cae166 |
diff --git a/lib/ssl/tls13con.c b/lib/ssl/tls13con.c
|
|
|
cae166 |
--- a/lib/ssl/tls13con.c
|
|
|
cae166 |
+++ b/lib/ssl/tls13con.c
|
|
|
cae166 |
@@ -4561,6 +4561,11 @@ tls13_ServerHandleFinished(sslSocket *ss
|
|
|
cae166 |
return SECFailure;
|
|
|
cae166 |
}
|
|
|
cae166 |
|
|
|
cae166 |
+ rv = tls13_FinishHandshake(ss);
|
|
|
cae166 |
+ if (rv != SECSuccess) {
|
|
|
cae166 |
+ return SECFailure;
|
|
|
cae166 |
+ }
|
|
|
cae166 |
+
|
|
|
cae166 |
ssl_GetXmitBufLock(ss);
|
|
|
cae166 |
if (ss->opt.enableSessionTickets) {
|
|
|
cae166 |
rv = tls13_SendNewSessionTicket(ss, NULL, 0);
|
|
|
cae166 |
@@ -4573,8 +4578,7 @@ tls13_ServerHandleFinished(sslSocket *ss
|
|
|
cae166 |
}
|
|
|
cae166 |
}
|
|
|
cae166 |
ssl_ReleaseXmitBufLock(ss);
|
|
|
cae166 |
-
|
|
|
cae166 |
- return tls13_FinishHandshake(ss);
|
|
|
cae166 |
+ return SECSuccess;
|
|
|
cae166 |
|
|
|
cae166 |
loser:
|
|
|
cae166 |
ssl_ReleaseXmitBufLock(ss);
|
|
|
cae166 |
diff --git a/tests/ssl/sslauth.txt b/tests/ssl/sslauth.txt
|
|
|
cae166 |
--- a/tests/ssl/sslauth.txt
|
|
|
cae166 |
+++ b/tests/ssl/sslauth.txt
|
|
|
cae166 |
@@ -42,6 +42,7 @@
|
|
|
cae166 |
noECC 0 -r_-r_-r_-r_-E -V_tls1.3:tls1.3_-E_-n_TestUser_-w_nss TLS 1.3 Require client auth on post hs (client auth)
|
|
|
cae166 |
noECC 0 -r_-r_-r_-E -V_tls1.3:tls1.3_-E_-n_none_-w_nss TLS 1.3 Request don't require client auth on post hs (client does not provide auth)
|
|
|
cae166 |
noECC 1 -r_-r_-r_-r_-E -V_tls1.3:tls1.3_-E_-n_none_-w_nss TLS 1.3 Require client auth on post hs (client does not provide auth)
|
|
|
cae166 |
+ noECC 0 -r_-r_-r_-E_-u -V_tls1.3:tls1.3_-E_-n_TestUser_-w_nss TLS 1.3 Request don't require client auth on post hs with session ticket (client auth)
|
|
|
cae166 |
#
|
|
|
cae166 |
# Use EC cert for client authentication
|
|
|
cae166 |
#
|