@@ -1211,6 +1211,33 @@ func TestHandshakeServerRSAPSS(t *testing.T) {
12111211 runServerTestTLS13 (t , test )
12121212}
12131213
1214+ func TestHandshakeServerPSSDisabled (t * testing.T ) {
1215+ test := & serverTest {
1216+ name : "RSA-PSS-Disabled" ,
1217+ command : []string {"openssl" , "s_client" , "-no_ticket" },
1218+ wait : true ,
1219+ }
1220+
1221+ // Restore the default signature algorithms, disabling RSA-PSS in TLS 1.2,
1222+ // and check that handshakes still work.
1223+ testSupportedSignatureAlgorithmsTLS12 := supportedSignatureAlgorithmsTLS12
1224+ defer func () { supportedSignatureAlgorithmsTLS12 = testSupportedSignatureAlgorithmsTLS12 }()
1225+ supportedSignatureAlgorithmsTLS12 = savedSupportedSignatureAlgorithmsTLS12
1226+
1227+ runServerTestTLS12 (t , test )
1228+ runServerTestTLS13 (t , test )
1229+
1230+ test = & serverTest {
1231+ name : "RSA-PSS-Disabled-Required" ,
1232+ command : []string {"openssl" , "s_client" , "-no_ticket" , "-sigalgs" , "rsa_pss_rsae_sha256" },
1233+ wait : true ,
1234+
1235+ expectHandshakeErrorIncluding : "peer doesn't support any common signature algorithms" ,
1236+ }
1237+
1238+ runServerTestTLS12 (t , test )
1239+ }
1240+
12141241func benchmarkHandshakeServer (b * testing.B , version uint16 , cipherSuite uint16 , curve CurveID , cert []byte , key crypto.PrivateKey ) {
12151242 config := testConfig .Clone ()
12161243 config .CipherSuites = []uint16 {cipherSuite }
@@ -1390,49 +1417,82 @@ func TestClientAuth(t *testing.T) {
13901417 defer os .Remove (ecdsaCertPath )
13911418 ecdsaKeyPath = tempFile (clientECDSAKeyPEM )
13921419 defer os .Remove (ecdsaKeyPath )
1393- } else {
1394- t .Parallel ()
13951420 }
13961421
1397- config := testConfig .Clone ()
1398- config .ClientAuth = RequestClientCert
1422+ t .Run ("Normal" , func (t * testing.T ) {
1423+ config := testConfig .Clone ()
1424+ config .ClientAuth = RequestClientCert
13991425
1400- test := & serverTest {
1401- name : "ClientAuthRequestedNotGiven" ,
1402- command : []string {"openssl" , "s_client" , "-no_ticket" , "-cipher" , "AES128-SHA" },
1403- config : config ,
1404- }
1405- runServerTestTLS12 (t , test )
1406- runServerTestTLS13 (t , test )
1426+ test := & serverTest {
1427+ name : "ClientAuthRequestedNotGiven" ,
1428+ command : []string {"openssl" , "s_client" , "-no_ticket" , "-cipher" , "AES128-SHA" },
1429+ config : config ,
1430+ }
1431+ runServerTestTLS12 (t , test )
1432+ runServerTestTLS13 (t , test )
14071433
1408- test = & serverTest {
1409- name : "ClientAuthRequestedAndGiven" ,
1410- command : []string {"openssl" , "s_client" , "-no_ticket" , "-cipher" , "AES128-SHA" ,
1411- "-cert" , certPath , "-key" , keyPath , "-sigalgs" , "rsa_pss_rsae_sha256" },
1412- config : config ,
1413- expectedPeerCerts : []string {clientCertificatePEM },
1414- }
1415- runServerTestTLS12 (t , test )
1416- runServerTestTLS13 (t , test )
1434+ config .ClientAuth = RequireAnyClientCert
14171435
1418- test = & serverTest {
1419- name : "ClientAuthRequestedAndECDSAGiven" ,
1420- command : []string {"openssl" , "s_client" , "-no_ticket" , "-cipher" , "AES128-SHA" ,
1421- "-cert" , ecdsaCertPath , "-key" , ecdsaKeyPath },
1422- config : config ,
1423- expectedPeerCerts : []string {clientECDSACertificatePEM },
1424- }
1425- runServerTestTLS12 (t , test )
1426- runServerTestTLS13 (t , test )
1436+ test = & serverTest {
1437+ name : "ClientAuthRequestedAndGiven" ,
1438+ command : []string {"openssl" , "s_client" , "-no_ticket" , "-cipher" , "AES128-SHA" ,
1439+ "-cert" , certPath , "-key" , keyPath , "-sigalgs" , "rsa_pss_rsae_sha256" },
1440+ config : config ,
1441+ expectedPeerCerts : []string {clientCertificatePEM },
1442+ }
1443+ runServerTestTLS12 (t , test )
1444+ runServerTestTLS13 (t , test )
1445+
1446+ test = & serverTest {
1447+ name : "ClientAuthRequestedAndECDSAGiven" ,
1448+ command : []string {"openssl" , "s_client" , "-no_ticket" , "-cipher" , "AES128-SHA" ,
1449+ "-cert" , ecdsaCertPath , "-key" , ecdsaKeyPath },
1450+ config : config ,
1451+ expectedPeerCerts : []string {clientECDSACertificatePEM },
1452+ }
1453+ runServerTestTLS12 (t , test )
1454+ runServerTestTLS13 (t , test )
1455+
1456+ test = & serverTest {
1457+ name : "ClientAuthRequestedAndPKCS1v15Given" ,
1458+ command : []string {"openssl" , "s_client" , "-no_ticket" , "-cipher" , "AES128-SHA" ,
1459+ "-cert" , certPath , "-key" , keyPath , "-sigalgs" , "rsa_pkcs1_sha256" },
1460+ config : config ,
1461+ expectedPeerCerts : []string {clientCertificatePEM },
1462+ }
1463+ runServerTestTLS12 (t , test )
1464+ })
14271465
1428- test = & serverTest {
1429- name : "ClientAuthRequestedAndPKCS1v15Given" ,
1430- command : []string {"openssl" , "s_client" , "-no_ticket" , "-cipher" , "AES128-SHA" ,
1431- "-cert" , certPath , "-key" , keyPath , "-sigalgs" , "rsa_pkcs1_sha256" },
1432- config : config ,
1433- expectedPeerCerts : []string {clientCertificatePEM },
1434- }
1435- runServerTestTLS12 (t , test )
1466+ // Restore the default signature algorithms, disabling RSA-PSS in TLS 1.2,
1467+ // and check that handshakes still work.
1468+ testSupportedSignatureAlgorithmsTLS12 := supportedSignatureAlgorithmsTLS12
1469+ defer func () { supportedSignatureAlgorithmsTLS12 = testSupportedSignatureAlgorithmsTLS12 }()
1470+ supportedSignatureAlgorithmsTLS12 = savedSupportedSignatureAlgorithmsTLS12
1471+
1472+ t .Run ("PSSDisabled" , func (t * testing.T ) {
1473+ config := testConfig .Clone ()
1474+ config .ClientAuth = RequireAnyClientCert
1475+
1476+ test := & serverTest {
1477+ name : "ClientAuthRequestedAndGiven-PSS-Disabled" ,
1478+ command : []string {"openssl" , "s_client" , "-no_ticket" , "-cipher" , "AES128-SHA" ,
1479+ "-cert" , certPath , "-key" , keyPath },
1480+ config : config ,
1481+ expectedPeerCerts : []string {clientCertificatePEM },
1482+ }
1483+ runServerTestTLS12 (t , test )
1484+ runServerTestTLS13 (t , test )
1485+
1486+ test = & serverTest {
1487+ name : "ClientAuthRequestedAndGiven-PSS-Disabled-Required" ,
1488+ command : []string {"openssl" , "s_client" , "-no_ticket" , "-cipher" , "AES128-SHA" ,
1489+ "-cert" , certPath , "-key" , keyPath , "-client_sigalgs" , "rsa_pss_rsae_sha256" },
1490+ config : config ,
1491+
1492+ expectHandshakeErrorIncluding : "client didn't provide a certificate" ,
1493+ }
1494+ runServerTestTLS12 (t , test )
1495+ })
14361496}
14371497
14381498func TestSNIGivenOnFailure (t * testing.T ) {
@@ -1722,6 +1782,7 @@ T+E0J8wlH24pgwQHzy7Ko2qLwn1b5PW8ecrlvP1g
17221782 if err != nil {
17231783 t .Fatal (err )
17241784 }
1785+
17251786 done := make (chan struct {})
17261787 go func () {
17271788 config := testConfig .Clone ()
@@ -1739,4 +1800,15 @@ T+E0J8wlH24pgwQHzy7Ko2qLwn1b5PW8ecrlvP1g
17391800 t .Errorf (`expected "handshake failure", got %q` , err )
17401801 }
17411802 <- done
1803+
1804+ // With RSA-PSS disabled and TLS 1.2, this should work.
1805+
1806+ testSupportedSignatureAlgorithmsTLS12 := supportedSignatureAlgorithmsTLS12
1807+ defer func () { supportedSignatureAlgorithmsTLS12 = testSupportedSignatureAlgorithmsTLS12 }()
1808+ supportedSignatureAlgorithmsTLS12 = savedSupportedSignatureAlgorithmsTLS12
1809+
1810+ serverConfig := testConfig .Clone ()
1811+ serverConfig .Certificates = []Certificate {cert }
1812+ serverConfig .MaxVersion = VersionTLS12
1813+ testHandshake (t , testConfig , serverConfig )
17421814}
0 commit comments