@@ -1211,6 +1211,33 @@ func TestHandshakeServerRSAPSS(t *testing.T) {
1211
1211
runServerTestTLS13 (t , test )
1212
1212
}
1213
1213
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
+
1214
1241
func benchmarkHandshakeServer (b * testing.B , version uint16 , cipherSuite uint16 , curve CurveID , cert []byte , key crypto.PrivateKey ) {
1215
1242
config := testConfig .Clone ()
1216
1243
config .CipherSuites = []uint16 {cipherSuite }
@@ -1390,49 +1417,82 @@ func TestClientAuth(t *testing.T) {
1390
1417
defer os .Remove (ecdsaCertPath )
1391
1418
ecdsaKeyPath = tempFile (clientECDSAKeyPEM )
1392
1419
defer os .Remove (ecdsaKeyPath )
1393
- } else {
1394
- t .Parallel ()
1395
1420
}
1396
1421
1397
- config := testConfig .Clone ()
1398
- config .ClientAuth = RequestClientCert
1422
+ t .Run ("Normal" , func (t * testing.T ) {
1423
+ config := testConfig .Clone ()
1424
+ config .ClientAuth = RequestClientCert
1399
1425
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 )
1407
1433
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
1417
1435
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
+ })
1427
1465
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
+ })
1436
1496
}
1437
1497
1438
1498
func TestSNIGivenOnFailure (t * testing.T ) {
@@ -1722,6 +1782,7 @@ T+E0J8wlH24pgwQHzy7Ko2qLwn1b5PW8ecrlvP1g
1722
1782
if err != nil {
1723
1783
t .Fatal (err )
1724
1784
}
1785
+
1725
1786
done := make (chan struct {})
1726
1787
go func () {
1727
1788
config := testConfig .Clone ()
@@ -1739,4 +1800,15 @@ T+E0J8wlH24pgwQHzy7Ko2qLwn1b5PW8ecrlvP1g
1739
1800
t .Errorf (`expected "handshake failure", got %q` , err )
1740
1801
}
1741
1802
<- 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 )
1742
1814
}
0 commit comments