@@ -2302,7 +2302,7 @@ func testHandshakeGetConfigForClientDifferentClientCAs(t *testing.T, version uin
23022302 if err != nil {
23032303 t .Fatalf ("ParseCertificate: %v" , err )
23042304 }
2305- rootDER , err = x509 .CreateCertificate (rand .Reader , tmpl , tmpl , & testECDSAPrivateKey .PublicKey , testECDSAPrivateKey )
2305+ rootDER , err = x509 .CreateCertificate (rand .Reader , tmpl , tmpl , & testRSA2048PrivateKey .PublicKey , testRSA2048PrivateKey )
23062306 if err != nil {
23072307 t .Fatalf ("CreateCertificate: %v" , err )
23082308 }
@@ -2318,15 +2318,19 @@ func testHandshakeGetConfigForClientDifferentClientCAs(t *testing.T, version uin
23182318 NotAfter : now .Add (time .Hour * 24 ),
23192319 KeyUsage : x509 .KeyUsageDigitalSignature ,
23202320 }
2321- certDER , err := x509 .CreateCertificate (rand .Reader , tmpl , rootA , & testECDSAPrivateKey .PublicKey , testECDSAPrivateKey )
2321+ certA , err := x509 .CreateCertificate (rand .Reader , tmpl , rootA , & testECDSAPrivateKey .PublicKey , testECDSAPrivateKey )
2322+ if err != nil {
2323+ t .Fatalf ("CreateCertificate: %v" , err )
2324+ }
2325+ certB , err := x509 .CreateCertificate (rand .Reader , tmpl , rootB , & testECDSAPrivateKey .PublicKey , testRSA2048PrivateKey )
23222326 if err != nil {
23232327 t .Fatalf ("CreateCertificate: %v" , err )
23242328 }
23252329
23262330 serverConfig := testConfig .Clone ()
23272331 serverConfig .MaxVersion = version
23282332 serverConfig .Certificates = []Certificate {{
2329- Certificate : [][]byte {certDER },
2333+ Certificate : [][]byte {certA },
23302334 PrivateKey : testECDSAPrivateKey ,
23312335 }}
23322336 serverConfig .Time = func () time.Time {
@@ -2351,7 +2355,7 @@ func testHandshakeGetConfigForClientDifferentClientCAs(t *testing.T, version uin
23512355 clientConfig := testConfig .Clone ()
23522356 clientConfig .MaxVersion = version
23532357 clientConfig .Certificates = []Certificate {{
2354- Certificate : [][]byte {certDER },
2358+ Certificate : [][]byte {certA },
23552359 PrivateKey : testECDSAPrivateKey ,
23562360 }}
23572361 clientConfig .ClientSessionCache = NewLRUClientSessionCache (32 )
@@ -2380,6 +2384,8 @@ func testHandshakeGetConfigForClientDifferentClientCAs(t *testing.T, version uin
23802384 testResume (t , serverConfig , clientConfig , false )
23812385 testResume (t , serverConfig , clientConfig , true )
23822386
2387+ clientConfig .Certificates [0 ].Certificate = [][]byte {certB }
2388+
23832389 // Cause GetConfigForClient to return a config cloned from the base config,
23842390 // but with a different ClientCAs pool. This should cause resumption to fail.
23852391 switchConfig = true
@@ -2414,7 +2420,7 @@ func testHandshakeChangeRootCAsResumption(t *testing.T, version uint16) {
24142420 if err != nil {
24152421 t .Fatalf ("ParseCertificate: %v" , err )
24162422 }
2417- rootDER , err = x509 .CreateCertificate (rand .Reader , tmpl , tmpl , & testECDSAPrivateKey .PublicKey , testECDSAPrivateKey )
2423+ rootDER , err = x509 .CreateCertificate (rand .Reader , tmpl , tmpl , & testRSA2048PrivateKey .PublicKey , testRSA2048PrivateKey )
24182424 if err != nil {
24192425 t .Fatalf ("CreateCertificate: %v" , err )
24202426 }
@@ -2430,15 +2436,19 @@ func testHandshakeChangeRootCAsResumption(t *testing.T, version uint16) {
24302436 NotAfter : now .Add (time .Hour * 24 ),
24312437 KeyUsage : x509 .KeyUsageDigitalSignature ,
24322438 }
2433- certDER , err := x509 .CreateCertificate (rand .Reader , tmpl , rootA , & testECDSAPrivateKey .PublicKey , testECDSAPrivateKey )
2439+ certA , err := x509 .CreateCertificate (rand .Reader , tmpl , rootA , & testECDSAPrivateKey .PublicKey , testECDSAPrivateKey )
2440+ if err != nil {
2441+ t .Fatalf ("CreateCertificate: %v" , err )
2442+ }
2443+ certB , err := x509 .CreateCertificate (rand .Reader , tmpl , rootB , & testECDSAPrivateKey .PublicKey , testRSA2048PrivateKey )
24342444 if err != nil {
24352445 t .Fatalf ("CreateCertificate: %v" , err )
24362446 }
24372447
24382448 serverConfig := testConfig .Clone ()
24392449 serverConfig .MaxVersion = version
24402450 serverConfig .Certificates = []Certificate {{
2441- Certificate : [][]byte {certDER },
2451+ Certificate : [][]byte {certA },
24422452 PrivateKey : testECDSAPrivateKey ,
24432453 }}
24442454 serverConfig .Time = func () time.Time {
@@ -2453,7 +2463,7 @@ func testHandshakeChangeRootCAsResumption(t *testing.T, version uint16) {
24532463 clientConfig := testConfig .Clone ()
24542464 clientConfig .MaxVersion = version
24552465 clientConfig .Certificates = []Certificate {{
2456- Certificate : [][]byte {certDER },
2466+ Certificate : [][]byte {certA },
24572467 PrivateKey : testECDSAPrivateKey ,
24582468 }}
24592469 clientConfig .ClientSessionCache = NewLRUClientSessionCache (32 )
@@ -2486,6 +2496,8 @@ func testHandshakeChangeRootCAsResumption(t *testing.T, version uint16) {
24862496 clientConfig .RootCAs = x509 .NewCertPool ()
24872497 clientConfig .RootCAs .AddCert (rootB )
24882498
2499+ serverConfig .Certificates [0 ].Certificate = [][]byte {certB }
2500+
24892501 testResume (t , serverConfig , clientConfig , false )
24902502 testResume (t , serverConfig , clientConfig , true )
24912503}
0 commit comments