crypto/tls: switch tests to new test certificates and keys

Change-Id: Ia2166ac4770a101723616fadff20948a6a6a6964
Reviewed-on: https://go-review.googlesource.com/c/go/+/776700
Auto-Submit: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Daniel McCarney <daniel@binaryparadox.net>
LUCI-TryBot-Result: golang-scoped@luci-project-accounts.iam.gserviceaccount.com <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
This commit is contained in:
Filippo Valsorda 2026-05-09 17:59:33 +02:00 committed by Gopher Robot
parent 320e0be23d
commit ca4f272170
8 changed files with 218 additions and 293 deletions

View file

@ -13,26 +13,11 @@ import (
)
func TestSignatureSelection(t *testing.T) {
rsaCert := &Certificate{
Certificate: [][]byte{testRSACertificate},
PrivateKey: testRSAPrivateKey,
}
pkcs1Cert := &Certificate{
Certificate: [][]byte{testRSACertificate},
PrivateKey: testRSAPrivateKey,
SupportedSignatureAlgorithms: []SignatureScheme{PKCS1WithSHA1, PKCS1WithSHA256},
}
ecdsaCert := &Certificate{
Certificate: [][]byte{testP256Certificate},
PrivateKey: testP256PrivateKey,
}
ed25519Cert := &Certificate{
Certificate: [][]byte{testEd25519Certificate},
PrivateKey: testEd25519PrivateKey,
}
pkcs1Cert := testRSA2048Cert
pkcs1Cert.SupportedSignatureAlgorithms = []SignatureScheme{PKCS1WithSHA1, PKCS1WithSHA256}
tests := []struct {
cert *Certificate
cert Certificate
peerSigAlgs []SignatureScheme
tlsVersion uint16
godebug string
@ -41,26 +26,26 @@ func TestSignatureSelection(t *testing.T) {
expectedSigType uint8
expectedHash crypto.Hash
}{
{rsaCert, []SignatureScheme{PKCS1WithSHA1, PKCS1WithSHA256}, VersionTLS12, "", PKCS1WithSHA256, signaturePKCS1v15, crypto.SHA256},
{rsaCert, []SignatureScheme{PKCS1WithSHA1, PKCS1WithSHA256}, VersionTLS12, "tlssha1=1", PKCS1WithSHA1, signaturePKCS1v15, crypto.SHA1},
{rsaCert, []SignatureScheme{PKCS1WithSHA512, PKCS1WithSHA1}, VersionTLS12, "", PKCS1WithSHA512, signaturePKCS1v15, crypto.SHA512},
{rsaCert, []SignatureScheme{PSSWithSHA256, PKCS1WithSHA256}, VersionTLS12, "", PSSWithSHA256, signatureRSAPSS, crypto.SHA256},
{testRSA2048Cert, []SignatureScheme{PKCS1WithSHA1, PKCS1WithSHA256}, VersionTLS12, "", PKCS1WithSHA256, signaturePKCS1v15, crypto.SHA256},
{testRSA2048Cert, []SignatureScheme{PKCS1WithSHA1, PKCS1WithSHA256}, VersionTLS12, "tlssha1=1", PKCS1WithSHA1, signaturePKCS1v15, crypto.SHA1},
{testRSA2048Cert, []SignatureScheme{PKCS1WithSHA512, PKCS1WithSHA1}, VersionTLS12, "", PKCS1WithSHA512, signaturePKCS1v15, crypto.SHA512},
{testRSA2048Cert, []SignatureScheme{PSSWithSHA256, PKCS1WithSHA256}, VersionTLS12, "", PSSWithSHA256, signatureRSAPSS, crypto.SHA256},
{pkcs1Cert, []SignatureScheme{PSSWithSHA256, PKCS1WithSHA256}, VersionTLS12, "", PKCS1WithSHA256, signaturePKCS1v15, crypto.SHA256},
{rsaCert, []SignatureScheme{PSSWithSHA384, PKCS1WithSHA1}, VersionTLS13, "", PSSWithSHA384, signatureRSAPSS, crypto.SHA384},
{rsaCert, []SignatureScheme{PKCS1WithSHA1, PSSWithSHA384}, VersionTLS13, "", PSSWithSHA384, signatureRSAPSS, crypto.SHA384},
{ecdsaCert, []SignatureScheme{ECDSAWithSHA1, ECDSAWithP256AndSHA256}, VersionTLS12, "", ECDSAWithP256AndSHA256, signatureECDSA, crypto.SHA256},
{ecdsaCert, []SignatureScheme{ECDSAWithSHA1}, VersionTLS12, "tlssha1=1", ECDSAWithSHA1, signatureECDSA, crypto.SHA1},
{ecdsaCert, []SignatureScheme{ECDSAWithP256AndSHA256}, VersionTLS12, "", ECDSAWithP256AndSHA256, signatureECDSA, crypto.SHA256},
{ecdsaCert, []SignatureScheme{ECDSAWithP256AndSHA256}, VersionTLS13, "", ECDSAWithP256AndSHA256, signatureECDSA, crypto.SHA256},
{ed25519Cert, []SignatureScheme{Ed25519}, VersionTLS12, "", Ed25519, signatureEd25519, directSigning},
{ed25519Cert, []SignatureScheme{Ed25519}, VersionTLS13, "", Ed25519, signatureEd25519, directSigning},
{testRSA2048Cert, []SignatureScheme{PSSWithSHA384, PKCS1WithSHA1}, VersionTLS13, "", PSSWithSHA384, signatureRSAPSS, crypto.SHA384},
{testRSA2048Cert, []SignatureScheme{PKCS1WithSHA1, PSSWithSHA384}, VersionTLS13, "", PSSWithSHA384, signatureRSAPSS, crypto.SHA384},
{testECDSAP256Cert, []SignatureScheme{ECDSAWithSHA1, ECDSAWithP256AndSHA256}, VersionTLS12, "", ECDSAWithP256AndSHA256, signatureECDSA, crypto.SHA256},
{testECDSAP256Cert, []SignatureScheme{ECDSAWithSHA1}, VersionTLS12, "tlssha1=1", ECDSAWithSHA1, signatureECDSA, crypto.SHA1},
{testECDSAP256Cert, []SignatureScheme{ECDSAWithP256AndSHA256}, VersionTLS12, "", ECDSAWithP256AndSHA256, signatureECDSA, crypto.SHA256},
{testECDSAP256Cert, []SignatureScheme{ECDSAWithP256AndSHA256}, VersionTLS13, "", ECDSAWithP256AndSHA256, signatureECDSA, crypto.SHA256},
{testEd25519Cert, []SignatureScheme{Ed25519}, VersionTLS12, "", Ed25519, signatureEd25519, directSigning},
{testEd25519Cert, []SignatureScheme{Ed25519}, VersionTLS13, "", Ed25519, signatureEd25519, directSigning},
// TLS 1.2 without signature_algorithms extension
{rsaCert, nil, VersionTLS12, "tlssha1=1", PKCS1WithSHA1, signaturePKCS1v15, crypto.SHA1},
{ecdsaCert, nil, VersionTLS12, "tlssha1=1", ECDSAWithSHA1, signatureECDSA, crypto.SHA1},
{testRSA2048Cert, nil, VersionTLS12, "tlssha1=1", PKCS1WithSHA1, signaturePKCS1v15, crypto.SHA1},
{testECDSAP256Cert, nil, VersionTLS12, "tlssha1=1", ECDSAWithSHA1, signatureECDSA, crypto.SHA1},
// TLS 1.2 does not restrict the ECDSA curve (our ecdsaCert is P-256)
{ecdsaCert, []SignatureScheme{ECDSAWithP384AndSHA384}, VersionTLS12, "", ECDSAWithP384AndSHA384, signatureECDSA, crypto.SHA384},
// TLS 1.2 does not restrict the ECDSA curve
{testECDSAP256Cert, []SignatureScheme{ECDSAWithP384AndSHA384}, VersionTLS12, "", ECDSAWithP384AndSHA384, signatureECDSA, crypto.SHA384},
}
for testNo, test := range tests {
@ -74,7 +59,7 @@ func TestSignatureSelection(t *testing.T) {
t.Parallel()
}
sigAlg, err := selectSignatureScheme(test.tlsVersion, test.cert, test.peerSigAlgs)
sigAlg, err := selectSignatureScheme(test.tlsVersion, &test.cert, test.peerSigAlgs)
if err != nil {
t.Errorf("unexpected selectSignatureScheme error: %v", err)
}
@ -94,49 +79,46 @@ func TestSignatureSelection(t *testing.T) {
})
}
brokenCert := &Certificate{
Certificate: [][]byte{testRSACertificate},
PrivateKey: testRSAPrivateKey,
SupportedSignatureAlgorithms: []SignatureScheme{Ed25519},
}
brokenCert := testRSA2048Cert
brokenCert.SupportedSignatureAlgorithms = []SignatureScheme{Ed25519}
badTests := []struct {
cert *Certificate
cert Certificate
peerSigAlgs []SignatureScheme
tlsVersion uint16
}{
{rsaCert, []SignatureScheme{ECDSAWithP256AndSHA256, ECDSAWithSHA1}, VersionTLS12},
{ecdsaCert, []SignatureScheme{PKCS1WithSHA256, PKCS1WithSHA1}, VersionTLS12},
{rsaCert, []SignatureScheme{0}, VersionTLS12},
{ed25519Cert, []SignatureScheme{ECDSAWithP256AndSHA256, ECDSAWithSHA1}, VersionTLS12},
{ecdsaCert, []SignatureScheme{Ed25519}, VersionTLS12},
{testRSA2048Cert, []SignatureScheme{ECDSAWithP256AndSHA256, ECDSAWithSHA1}, VersionTLS12},
{testECDSAP256Cert, []SignatureScheme{PKCS1WithSHA256, PKCS1WithSHA1}, VersionTLS12},
{testRSA2048Cert, []SignatureScheme{0}, VersionTLS12},
{testEd25519Cert, []SignatureScheme{ECDSAWithP256AndSHA256, ECDSAWithSHA1}, VersionTLS12},
{testECDSAP256Cert, []SignatureScheme{Ed25519}, VersionTLS12},
{brokenCert, []SignatureScheme{Ed25519}, VersionTLS12},
{brokenCert, []SignatureScheme{PKCS1WithSHA256}, VersionTLS12},
// RFC 5246, Section 7.4.1.4.1, says to only consider {sha1,ecdsa} as
// default when the extension is missing, and RFC 8422 does not update
// it. Anyway, if a stack supports Ed25519 it better support sigalgs.
{ed25519Cert, nil, VersionTLS12},
{testEd25519Cert, nil, VersionTLS12},
// TLS 1.3 has no default signature_algorithms.
{rsaCert, nil, VersionTLS13},
{ecdsaCert, nil, VersionTLS13},
{ed25519Cert, nil, VersionTLS13},
{testRSA2048Cert, nil, VersionTLS13},
{testECDSAP256Cert, nil, VersionTLS13},
{testEd25519Cert, nil, VersionTLS13},
// Wrong curve, which TLS 1.3 checks
{ecdsaCert, []SignatureScheme{ECDSAWithP384AndSHA384}, VersionTLS13},
{testECDSAP256Cert, []SignatureScheme{ECDSAWithP384AndSHA384}, VersionTLS13},
// TLS 1.3 does not support PKCS1v1.5 or SHA-1.
{rsaCert, []SignatureScheme{PKCS1WithSHA256}, VersionTLS13},
{testRSA2048Cert, []SignatureScheme{PKCS1WithSHA256}, VersionTLS13},
{pkcs1Cert, []SignatureScheme{PSSWithSHA256, PKCS1WithSHA256}, VersionTLS13},
{ecdsaCert, []SignatureScheme{ECDSAWithSHA1}, VersionTLS13},
{testECDSAP256Cert, []SignatureScheme{ECDSAWithSHA1}, VersionTLS13},
// The key can be too small for the hash.
{rsaCert, []SignatureScheme{PSSWithSHA512}, VersionTLS12},
{testRSA1024Cert, []SignatureScheme{PSSWithSHA512}, VersionTLS12},
// SHA-1 requires tlssha1=1
{rsaCert, []SignatureScheme{PKCS1WithSHA1}, VersionTLS12},
{ecdsaCert, []SignatureScheme{ECDSAWithSHA1}, VersionTLS12},
{rsaCert, nil, VersionTLS12},
{ecdsaCert, nil, VersionTLS12},
{testRSA2048Cert, []SignatureScheme{PKCS1WithSHA1}, VersionTLS12},
{testECDSAP256Cert, []SignatureScheme{ECDSAWithSHA1}, VersionTLS12},
{testRSA2048Cert, nil, VersionTLS12},
{testECDSAP256Cert, nil, VersionTLS12},
}
for testNo, test := range badTests {
sigAlg, err := selectSignatureScheme(test.tlsVersion, test.cert, test.peerSigAlgs)
sigAlg, err := selectSignatureScheme(test.tlsVersion, &test.cert, test.peerSigAlgs)
if err == nil {
t.Errorf("test[%d]: unexpected success, got %v", testNo, sigAlg)
}
@ -144,7 +126,7 @@ func TestSignatureSelection(t *testing.T) {
}
func TestLegacyTypeAndHash(t *testing.T) {
sigType, hashFunc, err := legacyTypeAndHashFromPublicKey(testRSAPrivateKey.Public())
sigType, hashFunc, err := legacyTypeAndHashFromPublicKey(testRSA2048Key.Public())
if err != nil {
t.Errorf("RSA: unexpected error: %v", err)
}
@ -155,7 +137,7 @@ func TestLegacyTypeAndHash(t *testing.T) {
t.Errorf("RSA: expected hash %#x, got %#x", expectedHashFunc, hashFunc)
}
sigType, hashFunc, err = legacyTypeAndHashFromPublicKey(testECDSAPrivateKey.Public())
sigType, hashFunc, err = legacyTypeAndHashFromPublicKey(testECDSAP256Key.Public())
if err != nil {
t.Errorf("ECDSA: unexpected error: %v", err)
}
@ -167,7 +149,7 @@ func TestLegacyTypeAndHash(t *testing.T) {
}
// Ed25519 is not supported by TLS 1.0 and 1.1.
_, _, err = legacyTypeAndHashFromPublicKey(testEd25519PrivateKey.Public())
_, _, err = legacyTypeAndHashFromPublicKey(testEd25519Key.Public())
if err == nil {
t.Errorf("Ed25519: unexpected success")
}

View file

@ -130,6 +130,7 @@ func TestGenerateCertificates(t *testing.T) {
comment string
certPEM string
keyPEM string
keyType string
}
var pairs []certKeyPair
@ -140,7 +141,7 @@ func TestGenerateCertificates(t *testing.T) {
}
certPEM := string(pem.EncodeToMemory(&pem.Block{Type: "CERTIFICATE", Bytes: certDER}))
keyPEM := string(pem.EncodeToMemory(&pem.Block{Type: "TESTING KEY", Bytes: keyDER}))
pairs = append(pairs, certKeyPair{name, comment, strings.TrimSpace(certPEM), strings.TrimSpace(keyPEM)})
pairs = append(pairs, certKeyPair{name, comment, strings.TrimSpace(certPEM), strings.TrimSpace(keyPEM), fmt.Sprintf("%T", key)})
}
// Roots.
@ -320,7 +321,12 @@ func TestGenerateCertificates(t *testing.T) {
package tls
import "crypto/x509"
import (
"crypto/ecdsa"
"crypto/ed25519"
"crypto/rsa"
"crypto/x509"
)
`)
@ -328,8 +334,10 @@ import "crypto/x509"
`)
for _, p := range pairs {
fmt.Fprintf(&buf, "\t// %s\n", p.comment)
fmt.Fprintf(&buf, "\t%sCert = parseTestCert(%sCertPEM, %sKeyPEM)\n\n",
fmt.Fprintf(&buf, "\t%sCert = parseTestCert(%sCertPEM, %sKeyPEM)\n",
p.name, p.name, p.name)
fmt.Fprintf(&buf, "\t%sKey = %sCert.PrivateKey.(%s)\n\n",
p.name, p.name, p.keyType)
}
fmt.Fprint(&buf, ` // x509.CertPool containing testRootCert.
testRootCertPool = newTestCertPool(testRootCertPEM)

View file

@ -3,57 +3,77 @@
package tls
import "crypto/x509"
import (
"crypto/ecdsa"
"crypto/ed25519"
"crypto/rsa"
"crypto/x509"
)
var (
// Self-signed RSA 2048 root CA, CN=Root.
testRootCert = parseTestCert(testRootCertPEM, testRootKeyPEM)
testRootKey = testRootCert.PrivateKey.(*rsa.PrivateKey)
// Self-signed RSA 2048 root CA, CN=Client Root.
testClientRootCert = parseTestCert(testClientRootCertPEM, testClientRootKeyPEM)
testClientRootKey = testClientRootCert.PrivateKey.(*rsa.PrivateKey)
// ECDSA P-256 server leaf, SAN=test.golang.example, issued by Root.
testECDSAP256Cert = parseTestCert(testECDSAP256CertPEM, testECDSAP256KeyPEM)
testECDSAP256Key = testECDSAP256Cert.PrivateKey.(*ecdsa.PrivateKey)
// RSA 2048 server leaf, SAN=test.golang.example, issued by Root.
testRSA2048Cert = parseTestCert(testRSA2048CertPEM, testRSA2048KeyPEM)
testRSA2048Key = testRSA2048Cert.PrivateKey.(*rsa.PrivateKey)
// ECDSA P-384 server leaf, SAN=test.golang.example, issued by Root.
testECDSAP384Cert = parseTestCert(testECDSAP384CertPEM, testECDSAP384KeyPEM)
testECDSAP384Key = testECDSAP384Cert.PrivateKey.(*ecdsa.PrivateKey)
// ECDSA P-521 server leaf, SAN=test.golang.example, issued by Root.
testECDSAP521Cert = parseTestCert(testECDSAP521CertPEM, testECDSAP521KeyPEM)
testECDSAP521Key = testECDSAP521Cert.PrivateKey.(*ecdsa.PrivateKey)
// Ed25519 server leaf, SAN=test.golang.example, issued by Root.
testEd25519Cert = parseTestCert(testEd25519CertPEM, testEd25519KeyPEM)
testEd25519Key = testEd25519Cert.PrivateKey.(ed25519.PrivateKey)
// RSA 2048 server leaf, SAN=test.golang.example, issued by Root.
// Signature algorithm is SHA512WithRSAPSS (rsaEncryption SPKI, rsassaPss signature).
testRSAPSSCert = parseTestCert(testRSAPSSCertPEM, testRSAPSSKeyPEM)
testRSAPSSKey = testRSAPSSCert.PrivateKey.(*rsa.PrivateKey)
// RSA 1024 server leaf, SAN=test.golang.example, issued by Root.
// Key is too small for rsa_pss_rsae_sha512; used by TestHandshakeServerRSAPSS.
testRSA1024Cert = parseTestCert(testRSA1024CertPEM, testRSA1024KeyPEM)
testRSA1024Key = testRSA1024Cert.PrivateKey.(*rsa.PrivateKey)
// RSA 512 server leaf, SAN=test.golang.example, issued by Root.
// Key is too small for any rsa_pss_rsae_*; used by TestKeyTooSmallForRSAPSS.
testRSA512Cert = parseTestCert(testRSA512CertPEM, testRSA512KeyPEM)
testRSA512Key = testRSA512Cert.PrivateKey.(*rsa.PrivateKey)
// ECDSA P-256 server leaf, SAN=different.example.com, issued by Root.
testSNICert = parseTestCert(testSNICertPEM, testSNIKeyPEM)
testSNIKey = testSNICert.PrivateKey.(*ecdsa.PrivateKey)
// RSA 2048 client leaf, SAN=test.golang.example, issued by Client Root.
testClientRSA2048Cert = parseTestCert(testClientRSA2048CertPEM, testClientRSA2048KeyPEM)
testClientRSA2048Key = testClientRSA2048Cert.PrivateKey.(*rsa.PrivateKey)
// ECDSA P-256 client leaf, SAN=test.golang.example, issued by Client Root.
testClientECDSAP256Cert = parseTestCert(testClientECDSAP256CertPEM, testClientECDSAP256KeyPEM)
testClientECDSAP256Key = testClientECDSAP256Cert.PrivateKey.(*ecdsa.PrivateKey)
// Ed25519 client leaf, SAN=test.golang.example, issued by Client Root.
testClientEd25519Cert = parseTestCert(testClientEd25519CertPEM, testClientEd25519KeyPEM)
testClientEd25519Key = testClientEd25519Cert.PrivateKey.(ed25519.PrivateKey)
// RSA 2048 client leaf, SAN=test.golang.example, issued by Client Root.
// Signature algorithm is SHA512WithRSAPSS (rsaEncryption SPKI, rsassaPss signature).
testClientRSAPSSCert = parseTestCert(testClientRSAPSSCertPEM, testClientRSAPSSKeyPEM)
testClientRSAPSSKey = testClientRSAPSSCert.PrivateKey.(*rsa.PrivateKey)
// x509.CertPool containing testRootCert.
testRootCertPool = newTestCertPool(testRootCertPEM)

View file

@ -910,7 +910,7 @@ func testResumption(t *testing.T, version uint16) {
}
// Note: using RSA 2048 test certificates because they are compatible with FIPS mode.
testCertificates := []Certificate{{Certificate: [][]byte{testRSA2048Certificate}, PrivateKey: testRSA2048PrivateKey}}
testCertificates := []Certificate{testRSA2048Cert}
serverConfig := &Config{
MaxVersion: version,
CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384},
@ -918,20 +918,12 @@ func testResumption(t *testing.T, version uint16) {
Time: testTime,
}
issuer, err := x509.ParseCertificate(testRSA2048CertificateIssuer)
if err != nil {
panic(err)
}
rootCAs := x509.NewCertPool()
rootCAs.AddCert(issuer)
clientConfig := &Config{
MaxVersion: version,
CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256},
ClientSessionCache: NewLRUClientSessionCache(32),
RootCAs: rootCAs,
ServerName: "example.golang",
RootCAs: testRootCertPool,
ServerName: "test.golang.example",
Time: testTime,
}
@ -1091,9 +1083,9 @@ func testResumption(t *testing.T, version uint16) {
// Session resumption should work when using client certificates
deleteTicket()
serverConfig.ClientCAs = rootCAs
serverConfig.ClientCAs = testClientRootCertPool
serverConfig.ClientAuth = RequireAndVerifyClientCert
clientConfig.Certificates = serverConfig.Certificates
clientConfig.Certificates = []Certificate{testClientRSA2048Cert}
testResumeState("InitialHandshake", false)
testResumeState("WithClientCertificates", true)
serverConfig.ClientAuth = NoClientCert
@ -1102,7 +1094,7 @@ func testResumption(t *testing.T, version uint16) {
// failure, and the client should recover from a corrupted PSK
testResumeState("FetchTicketToCorrupt", false)
corruptTicket()
_, _, err = testHandshake(t, clientConfig, serverConfig)
_, _, err := testHandshake(t, clientConfig, serverConfig)
if err == nil {
t.Fatalf("handshake did not fail with a corrupted client secret")
}
@ -1620,8 +1612,8 @@ func testVerifyConnection(t *testing.T, version uint16) {
if c.HandshakeComplete {
return fmt.Errorf("%s: got HandshakeComplete, want false", errorType)
}
if c.ServerName != "example.golang" {
return fmt.Errorf("%s: got ServerName %s, want %s", errorType, c.ServerName, "example.golang")
if c.ServerName != "test.golang.example" {
return fmt.Errorf("%s: got ServerName %s, want %s", errorType, c.ServerName, "test.golang.example")
}
if c.NegotiatedProtocol != "protocol1" {
return fmt.Errorf("%s: got NegotiatedProtocol %s, want %s", errorType, c.NegotiatedProtocol, "protocol1")
@ -1777,22 +1769,13 @@ func testVerifyConnection(t *testing.T, version uint16) {
}
for _, test := range tests {
// Note: using RSA 2048 test certificates because they are compatible with FIPS mode.
testCertificates := []Certificate{{Certificate: [][]byte{testRSA2048Certificate}, PrivateKey: testRSA2048PrivateKey}}
issuer, err := x509.ParseCertificate(testRSA2048CertificateIssuer)
if err != nil {
panic(err)
}
rootCAs := x509.NewCertPool()
rootCAs.AddCert(issuer)
var serverCalled, clientCalled int
serverConfig := &Config{
MaxVersion: version,
Certificates: testCertificates,
Certificates: []Certificate{testRSA2048Cert},
Time: testTime,
ClientCAs: rootCAs,
ClientCAs: testClientRootCertPool,
NextProtos: []string{"protocol1"},
}
serverConfig.Certificates[0].SignedCertificateTimestamps = [][]byte{[]byte("dummy sct 1"), []byte("dummy sct 2")}
@ -1802,9 +1785,9 @@ func testVerifyConnection(t *testing.T, version uint16) {
clientConfig := &Config{
MaxVersion: version,
ClientSessionCache: NewLRUClientSessionCache(32),
RootCAs: rootCAs,
ServerName: "example.golang",
Certificates: testCertificates,
RootCAs: testRootCertPool,
ServerName: "test.golang.example",
Certificates: []Certificate{testClientRSA2048Cert},
Time: testTime,
NextProtos: []string{"protocol1"},
}
@ -1841,14 +1824,6 @@ func TestVerifyPeerCertificate(t *testing.T) {
func testVerifyPeerCertificate(t *testing.T, version uint16) {
// Note: using RSA 2048 test certificates because they are compatible with FIPS mode.
issuer, err := x509.ParseCertificate(testRSA2048CertificateIssuer)
if err != nil {
panic(err)
}
rootCAs := x509.NewCertPool()
rootCAs.AddCert(issuer)
sentinelErr := errors.New("TestVerifyPeerCertificate")
verifyPeerCertificateCallback := func(called *bool, rawCerts [][]byte, validatedChains [][]*x509.Certificate) error {
@ -2091,27 +2066,25 @@ func testVerifyPeerCertificate(t *testing.T, version uint16) {
go func() {
config := testConfig.Clone()
config.ServerName = "example.golang"
config.ServerName = "test.golang.example"
config.ClientAuth = RequireAndVerifyClientCert
config.ClientCAs = rootCAs
config.ClientCAs = testClientRootCertPool
config.Time = testTime
config.MaxVersion = version
config.Certificates = make([]Certificate, 1)
config.Certificates[0].Certificate = [][]byte{testRSA2048Certificate}
config.Certificates[0].PrivateKey = testRSA2048PrivateKey
config.Certificates = []Certificate{testRSA2048Cert}
config.Certificates[0].SignedCertificateTimestamps = [][]byte{[]byte("dummy sct 1"), []byte("dummy sct 2")}
config.Certificates[0].OCSPStaple = []byte("dummy ocsp")
test.configureServer(config, &serverCalled)
err = Server(s, config).Handshake()
err := Server(s, config).Handshake()
s.Close()
done <- err
}()
config := testConfig.Clone()
config.Certificates = []Certificate{{Certificate: [][]byte{testRSA2048Certificate}, PrivateKey: testRSA2048PrivateKey}}
config.ServerName = "example.golang"
config.RootCAs = rootCAs
config.Certificates = []Certificate{testClientRSA2048Cert}
config.ServerName = "test.golang.example"
config.RootCAs = testRootCertPool
config.Time = testTime
config.MaxVersion = version
test.configureClient(config, &clientCalled)
@ -2239,10 +2212,10 @@ func TestAlertFlushing(t *testing.T) {
serverConfig := testConfig.Clone()
// Cause a signature-time error
brokenKey := rsa.PrivateKey{PublicKey: testRSAPrivateKey.PublicKey}
brokenKey := rsa.PrivateKey{PublicKey: testRSA2048Key.PublicKey}
brokenKey.D = big.NewInt(42)
serverConfig.Certificates = []Certificate{{
Certificate: [][]byte{testRSACertificate},
Certificate: testRSA2048Cert.Certificate,
PrivateKey: &brokenKey,
}}
@ -2392,10 +2365,7 @@ var getClientCertificateTests = []struct {
if len(cri.AcceptableCAs) == 0 {
panic("empty AcceptableCAs")
}
cert := &Certificate{
Certificate: [][]byte{testRSA2048Certificate},
PrivateKey: testRSA2048PrivateKey,
}
cert := &testClientRSA2048Cert
return cert, nil
}
},
@ -2415,23 +2385,17 @@ func TestGetClientCertificate(t *testing.T) {
func testGetClientCertificate(t *testing.T, version uint16) {
// Note: using RSA 2048 test certificates because they are compatible with FIPS mode.
issuer, err := x509.ParseCertificate(testRSA2048CertificateIssuer)
if err != nil {
panic(err)
}
for i, test := range getClientCertificateTests {
serverConfig := testConfig.Clone()
serverConfig.Certificates = []Certificate{{Certificate: [][]byte{testRSA2048Certificate}, PrivateKey: testRSA2048PrivateKey}}
serverConfig.Certificates = []Certificate{testRSA2048Cert}
serverConfig.ClientAuth = VerifyClientCertIfGiven
serverConfig.RootCAs = x509.NewCertPool()
serverConfig.RootCAs.AddCert(issuer)
serverConfig.ClientCAs = serverConfig.RootCAs
serverConfig.RootCAs = testRootCertPool
serverConfig.ClientCAs = testClientRootCertPool
serverConfig.Time = testTime
serverConfig.MaxVersion = version
clientConfig := testConfig.Clone()
clientConfig.Certificates = []Certificate{{Certificate: [][]byte{testRSA2048Certificate}, PrivateKey: testRSA2048PrivateKey}}
clientConfig.Certificates = []Certificate{testClientRSA2048Cert}
clientConfig.MaxVersion = version
test.setup(clientConfig, serverConfig)
@ -2599,21 +2563,15 @@ func TestResumptionKeepsOCSPAndSCT(t *testing.T) {
func testResumptionKeepsOCSPAndSCT(t *testing.T, ver uint16) {
// Note: using RSA 2048 test certificates because they are compatible with FIPS mode.
issuer, err := x509.ParseCertificate(testRSA2048CertificateIssuer)
if err != nil {
t.Fatalf("failed to parse test issuer")
}
roots := x509.NewCertPool()
roots.AddCert(issuer)
clientConfig := &Config{
MaxVersion: ver,
ClientSessionCache: NewLRUClientSessionCache(32),
ServerName: "example.golang",
RootCAs: roots,
ServerName: "test.golang.example",
RootCAs: testRootCertPool,
Time: testTime,
}
serverConfig := testConfig.Clone()
serverConfig.Certificates = []Certificate{{Certificate: [][]byte{testRSA2048Certificate}, PrivateKey: testRSA2048PrivateKey}}
serverConfig.Certificates = []Certificate{testRSA2048Cert}
serverConfig.MaxVersion = ver
serverConfig.Certificates[0].OCSPStaple = []byte{1, 2, 3}
serverConfig.Certificates[0].SignedCertificateTimestamps = [][]byte{{4, 5, 6}}

View file

@ -360,16 +360,8 @@ func (*newSessionTicketMsg) Generate(rand *rand.Rand, size int) reflect.Value {
var sessionTestCerts []*x509.Certificate
func init() {
cert, err := x509.ParseCertificate(testRSACertificate)
if err != nil {
panic(err)
}
sessionTestCerts = append(sessionTestCerts, cert)
cert, err = x509.ParseCertificate(testRSACertificateIssuer)
if err != nil {
panic(err)
}
sessionTestCerts = append(sessionTestCerts, cert)
sessionTestCerts = append(sessionTestCerts, testRSA2048Cert.Leaf)
sessionTestCerts = append(sessionTestCerts, testRootCert.Leaf)
}
func (*SessionState) Generate(rand *rand.Rand, size int) reflect.Value {

View file

@ -175,8 +175,7 @@ func TestDontSelectECDSAWithRSAKey(t *testing.T) {
serverConfig := testConfig.Clone()
serverConfig.CipherSuites = clientHello.cipherSuites
serverConfig.Certificates = make([]Certificate, 1)
serverConfig.Certificates[0].Certificate = [][]byte{testECDSACertificate}
serverConfig.Certificates[0].PrivateKey = testECDSAPrivateKey
serverConfig.Certificates[0] = testECDSAP256Cert
serverConfig.BuildNameToCertificate()
// First test that it *does* work when the server's key is ECDSA.
testClientHello(t, serverConfig, clientHello)
@ -206,8 +205,7 @@ func TestDontSelectRSAWithECDSAKey(t *testing.T) {
// Now test that switching to an ECDSA key causes the expected error
// (and not an internal error about a signing failure).
serverConfig.Certificates = make([]Certificate, 1)
serverConfig.Certificates[0].Certificate = [][]byte{testECDSACertificate}
serverConfig.Certificates[0].PrivateKey = testECDSAPrivateKey
serverConfig.Certificates[0] = testECDSAP256Cert
serverConfig.BuildNameToCertificate()
testClientHelloFailure(t, serverConfig, clientHello, "no cipher suite supported by both client and server")
}
@ -355,7 +353,7 @@ func TestTLSPointFormats(t *testing.T) {
replyChan := make(chan any)
go func() {
clientConfig := testConfig.Clone()
clientConfig.Certificates = []Certificate{{Certificate: [][]byte{testRSA2048Certificate}, PrivateKey: testRSA2048PrivateKey}}
clientConfig.Certificates = []Certificate{testRSA2048Cert}
cli := Client(c, clientConfig)
cli.vers = clientHello.vers
if _, err := cli.writeHandshakeRecord(clientHello, nil); err != nil {
@ -370,7 +368,7 @@ func TestTLSPointFormats(t *testing.T) {
}
}()
serverConfig := testConfig.Clone()
serverConfig.Certificates = []Certificate{{Certificate: [][]byte{testRSA2048Certificate}, PrivateKey: testRSA2048PrivateKey}}
serverConfig.Certificates = []Certificate{testRSA2048Cert}
serverConfig.CipherSuites = clientHello.cipherSuites
Server(s, serverConfig).Handshake()
s.Close()
@ -483,13 +481,11 @@ func TestSCTHandshake(t *testing.T) {
func testSCTHandshake(t *testing.T, version uint16) {
expected := [][]byte{[]byte("certificate"), []byte("transparency")}
cert := testRSA2048Cert
cert.SignedCertificateTimestamps = expected
serverConfig := &Config{
Certificates: []Certificate{{
Certificate: [][]byte{testRSACertificate},
PrivateKey: testRSAPrivateKey,
SignedCertificateTimestamps: expected,
}},
MaxVersion: version,
Certificates: []Certificate{cert},
MaxVersion: version,
}
clientConfig := &Config{
InsecureSkipVerify: true,
@ -1444,49 +1440,49 @@ func benchmarkHandshakeServer(b *testing.B, version uint16, cipherSuite uint16,
func BenchmarkHandshakeServer(b *testing.B) {
b.Run("RSA", func(b *testing.B) {
benchmarkHandshakeServer(b, VersionTLS12, TLS_RSA_WITH_AES_128_GCM_SHA256,
0, testRSACertificate, testRSAPrivateKey)
0, testRSA2048Cert.Certificate[0], testRSA2048Key)
})
b.Run("ECDHE-P256-RSA", func(b *testing.B) {
b.Run("TLSv13", func(b *testing.B) {
benchmarkHandshakeServer(b, VersionTLS13, TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256,
CurveP256, testRSACertificate, testRSAPrivateKey)
CurveP256, testRSA2048Cert.Certificate[0], testRSA2048Key)
})
b.Run("TLSv12", func(b *testing.B) {
benchmarkHandshakeServer(b, VersionTLS12, TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256,
CurveP256, testRSACertificate, testRSAPrivateKey)
CurveP256, testRSA2048Cert.Certificate[0], testRSA2048Key)
})
})
b.Run("ECDHE-P256-ECDSA-P256", func(b *testing.B) {
b.Run("TLSv13", func(b *testing.B) {
benchmarkHandshakeServer(b, VersionTLS13, TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256,
CurveP256, testP256Certificate, testP256PrivateKey)
CurveP256, testECDSAP256Cert.Certificate[0], testECDSAP256Key)
})
b.Run("TLSv12", func(b *testing.B) {
benchmarkHandshakeServer(b, VersionTLS12, TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256,
CurveP256, testP256Certificate, testP256PrivateKey)
CurveP256, testECDSAP256Cert.Certificate[0], testECDSAP256Key)
})
})
b.Run("ECDHE-X25519-ECDSA-P256", func(b *testing.B) {
b.Run("TLSv13", func(b *testing.B) {
benchmarkHandshakeServer(b, VersionTLS13, TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256,
X25519, testP256Certificate, testP256PrivateKey)
X25519, testECDSAP256Cert.Certificate[0], testECDSAP256Key)
})
b.Run("TLSv12", func(b *testing.B) {
benchmarkHandshakeServer(b, VersionTLS12, TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256,
X25519, testP256Certificate, testP256PrivateKey)
X25519, testECDSAP256Cert.Certificate[0], testECDSAP256Key)
})
})
b.Run("ECDHE-P521-ECDSA-P521", func(b *testing.B) {
if testECDSAPrivateKey.PublicKey.Curve != elliptic.P521() {
if testECDSAP521Key.PublicKey.Curve != elliptic.P521() {
b.Fatal("test ECDSA key doesn't use curve P-521")
}
b.Run("TLSv13", func(b *testing.B) {
benchmarkHandshakeServer(b, VersionTLS13, TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256,
CurveP521, testECDSACertificate, testECDSAPrivateKey)
CurveP521, testECDSAP521Cert.Certificate[0], testECDSAP521Key)
})
b.Run("TLSv12", func(b *testing.B) {
benchmarkHandshakeServer(b, VersionTLS12, TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256,
CurveP521, testECDSACertificate, testECDSAPrivateKey)
CurveP521, testECDSAP521Cert.Certificate[0], testECDSAP521Key)
})
})
}
@ -1798,13 +1794,7 @@ func TestMultipleCertificates(t *testing.T) {
clientConfig.MaxVersion = VersionTLS12
serverConfig := testConfig.Clone()
serverConfig.Certificates = []Certificate{{
Certificate: [][]byte{testECDSACertificate},
PrivateKey: testECDSAPrivateKey,
}, {
Certificate: [][]byte{testRSACertificate},
PrivateKey: testRSAPrivateKey,
}}
serverConfig.Certificates = []Certificate{testECDSAP256Cert, testRSA2048Cert}
_, clientState, err := testHandshake(t, clientConfig, serverConfig)
if err != nil {
@ -2116,10 +2106,7 @@ func TestHandshakeContextHierarchy(t *testing.T) {
t.Errorf("GetClientCertificate context was not child of HandshakeContext")
}
innerCtx = certificateRequest.Context()
return &Certificate{
Certificate: [][]byte{testRSACertificate},
PrivateKey: testRSAPrivateKey,
}, nil
return &testRSA2048Cert, nil
}
cli := Client(c, clientConfig)
err := cli.HandshakeContext(ctx)
@ -2141,10 +2128,7 @@ func TestHandshakeContextHierarchy(t *testing.T) {
t.Errorf("GetClientCertificate context was not child of HandshakeContext")
}
innerCtx = clientHello.Context()
return &Certificate{
Certificate: [][]byte{testRSACertificate},
PrivateKey: testRSAPrivateKey,
}, nil
return &testRSA2048Cert, nil
}
conn := Server(s, serverConfig)
err := conn.HandshakeContext(ctx)
@ -2181,7 +2165,7 @@ func testHandshakeChainExpiryResumption(t *testing.T, version uint16) {
IsCA: true,
BasicConstraintsValid: true,
}
rootDER, err := x509.CreateCertificate(rand.Reader, tmpl, tmpl, &testECDSAPrivateKey.PublicKey, testECDSAPrivateKey)
rootDER, err := x509.CreateCertificate(rand.Reader, tmpl, tmpl, &testECDSAP521Key.PublicKey, testECDSAP521Key)
if err != nil {
t.Fatalf("CreateCertificate: %v", err)
}
@ -2197,12 +2181,12 @@ func testHandshakeChainExpiryResumption(t *testing.T, version uint16) {
NotAfter: leafNotAfter,
KeyUsage: x509.KeyUsageDigitalSignature,
}
leafCertDER, err := x509.CreateCertificate(rand.Reader, tmpl, root, &testECDSAPrivateKey.PublicKey, testECDSAPrivateKey)
leafCertDER, err := x509.CreateCertificate(rand.Reader, tmpl, root, &testECDSAP256Key.PublicKey, testECDSAP521Key)
if err != nil {
t.Fatalf("CreateCertificate: %v", err)
}
tmpl.NotBefore, tmpl.NotAfter = leafNotAfter.Add(-time.Hour*24*365), leafNotAfter.Add(-time.Hour*24*364)
expiredLeafDERCertDER, err := x509.CreateCertificate(rand.Reader, tmpl, root, &testECDSAPrivateKey.PublicKey, testECDSAPrivateKey)
expiredLeafDERCertDER, err := x509.CreateCertificate(rand.Reader, tmpl, root, &testECDSAP256Key.PublicKey, testECDSAP521Key)
if err != nil {
t.Fatalf("CreateCertificate: %v", err)
}
@ -2217,7 +2201,7 @@ func testHandshakeChainExpiryResumption(t *testing.T, version uint16) {
serverConfig.MaxVersion = version
serverConfig.Certificates = []Certificate{{
Certificate: [][]byte{initialLeafDER, expiredLeafDER},
PrivateKey: testECDSAPrivateKey,
PrivateKey: testECDSAP256Key,
}}
serverConfig.ClientCAs = x509.NewCertPool()
serverConfig.ClientCAs.AddCert(initialRoot)
@ -2232,7 +2216,7 @@ func testHandshakeChainExpiryResumption(t *testing.T, version uint16) {
clientConfig.MaxVersion = version
clientConfig.Certificates = []Certificate{{
Certificate: [][]byte{initialLeafDER, expiredLeafDER},
PrivateKey: testECDSAPrivateKey,
PrivateKey: testECDSAP256Key,
}}
clientConfig.RootCAs = x509.NewCertPool()
clientConfig.RootCAs.AddCert(initialRoot)
@ -2266,7 +2250,7 @@ func testHandshakeChainExpiryResumption(t *testing.T, version uint16) {
freshLeafDER, expiredLeafDER, freshRoot := createChain(expiredNow.Add(time.Hour), expiredNow.Add(time.Hour))
clientConfig.Certificates = []Certificate{{
Certificate: [][]byte{freshLeafDER, expiredLeafDER},
PrivateKey: testECDSAPrivateKey,
PrivateKey: testECDSAP256Key,
}}
serverConfig.Time = func() time.Time {
return expiredNow
@ -2300,7 +2284,7 @@ func testHandshakeGetConfigForClientDifferentClientCAs(t *testing.T, version uin
IsCA: true,
BasicConstraintsValid: true,
}
rootDER, err := x509.CreateCertificate(rand.Reader, tmpl, tmpl, &testECDSAPrivateKey.PublicKey, testECDSAPrivateKey)
rootDER, err := x509.CreateCertificate(rand.Reader, tmpl, tmpl, &testECDSAP521Key.PublicKey, testECDSAP521Key)
if err != nil {
t.Fatalf("CreateCertificate: %v", err)
}
@ -2308,7 +2292,7 @@ func testHandshakeGetConfigForClientDifferentClientCAs(t *testing.T, version uin
if err != nil {
t.Fatalf("ParseCertificate: %v", err)
}
rootDER, err = x509.CreateCertificate(rand.Reader, tmpl, tmpl, &testRSA2048PrivateKey.PublicKey, testRSA2048PrivateKey)
rootDER, err = x509.CreateCertificate(rand.Reader, tmpl, tmpl, &testRSA2048Key.PublicKey, testRSA2048Key)
if err != nil {
t.Fatalf("CreateCertificate: %v", err)
}
@ -2324,11 +2308,11 @@ func testHandshakeGetConfigForClientDifferentClientCAs(t *testing.T, version uin
NotAfter: now.Add(time.Hour * 24),
KeyUsage: x509.KeyUsageDigitalSignature,
}
certA, err := x509.CreateCertificate(rand.Reader, tmpl, rootA, &testECDSAPrivateKey.PublicKey, testECDSAPrivateKey)
certA, err := x509.CreateCertificate(rand.Reader, tmpl, rootA, &testECDSAP256Key.PublicKey, testECDSAP521Key)
if err != nil {
t.Fatalf("CreateCertificate: %v", err)
}
certB, err := x509.CreateCertificate(rand.Reader, tmpl, rootB, &testECDSAPrivateKey.PublicKey, testRSA2048PrivateKey)
certB, err := x509.CreateCertificate(rand.Reader, tmpl, rootB, &testECDSAP256Key.PublicKey, testRSA2048Key)
if err != nil {
t.Fatalf("CreateCertificate: %v", err)
}
@ -2337,7 +2321,7 @@ func testHandshakeGetConfigForClientDifferentClientCAs(t *testing.T, version uin
serverConfig.MaxVersion = version
serverConfig.Certificates = []Certificate{{
Certificate: [][]byte{certA},
PrivateKey: testECDSAPrivateKey,
PrivateKey: testECDSAP256Key,
}}
serverConfig.Time = func() time.Time {
return now
@ -2362,7 +2346,7 @@ func testHandshakeGetConfigForClientDifferentClientCAs(t *testing.T, version uin
clientConfig.MaxVersion = version
clientConfig.Certificates = []Certificate{{
Certificate: [][]byte{certA},
PrivateKey: testECDSAPrivateKey,
PrivateKey: testECDSAP256Key,
}}
clientConfig.ClientSessionCache = NewLRUClientSessionCache(32)
clientConfig.RootCAs = x509.NewCertPool()
@ -2418,7 +2402,7 @@ func testHandshakeChangeRootCAsResumption(t *testing.T, version uint16) {
IsCA: true,
BasicConstraintsValid: true,
}
rootDER, err := x509.CreateCertificate(rand.Reader, tmpl, tmpl, &testECDSAPrivateKey.PublicKey, testECDSAPrivateKey)
rootDER, err := x509.CreateCertificate(rand.Reader, tmpl, tmpl, &testECDSAP521Key.PublicKey, testECDSAP521Key)
if err != nil {
t.Fatalf("CreateCertificate: %v", err)
}
@ -2426,7 +2410,7 @@ func testHandshakeChangeRootCAsResumption(t *testing.T, version uint16) {
if err != nil {
t.Fatalf("ParseCertificate: %v", err)
}
rootDER, err = x509.CreateCertificate(rand.Reader, tmpl, tmpl, &testRSA2048PrivateKey.PublicKey, testRSA2048PrivateKey)
rootDER, err = x509.CreateCertificate(rand.Reader, tmpl, tmpl, &testRSA2048Key.PublicKey, testRSA2048Key)
if err != nil {
t.Fatalf("CreateCertificate: %v", err)
}
@ -2442,11 +2426,11 @@ func testHandshakeChangeRootCAsResumption(t *testing.T, version uint16) {
NotAfter: now.Add(time.Hour * 24),
KeyUsage: x509.KeyUsageDigitalSignature,
}
certA, err := x509.CreateCertificate(rand.Reader, tmpl, rootA, &testECDSAPrivateKey.PublicKey, testECDSAPrivateKey)
certA, err := x509.CreateCertificate(rand.Reader, tmpl, rootA, &testECDSAP256Key.PublicKey, testECDSAP521Key)
if err != nil {
t.Fatalf("CreateCertificate: %v", err)
}
certB, err := x509.CreateCertificate(rand.Reader, tmpl, rootB, &testECDSAPrivateKey.PublicKey, testRSA2048PrivateKey)
certB, err := x509.CreateCertificate(rand.Reader, tmpl, rootB, &testECDSAP256Key.PublicKey, testRSA2048Key)
if err != nil {
t.Fatalf("CreateCertificate: %v", err)
}
@ -2455,7 +2439,7 @@ func testHandshakeChangeRootCAsResumption(t *testing.T, version uint16) {
serverConfig.MaxVersion = version
serverConfig.Certificates = []Certificate{{
Certificate: [][]byte{certA},
PrivateKey: testECDSAPrivateKey,
PrivateKey: testECDSAP256Key,
}}
serverConfig.Time = func() time.Time {
return now
@ -2470,7 +2454,7 @@ func testHandshakeChangeRootCAsResumption(t *testing.T, version uint16) {
clientConfig.MaxVersion = version
clientConfig.Certificates = []Certificate{{
Certificate: [][]byte{certA},
PrivateKey: testECDSAPrivateKey,
PrivateKey: testECDSAP256Key,
}}
clientConfig.ClientSessionCache = NewLRUClientSessionCache(32)
clientConfig.RootCAs = x509.NewCertPool()

View file

@ -8,7 +8,6 @@ import (
"bufio"
"bytes"
"context"
"crypto/ed25519"
"crypto/x509"
"encoding/hex"
"errors"
@ -576,8 +575,6 @@ var testRSAPSSCertificate = fromHex("308202583082018da003020102021100f29926eb87e
var testECDSACertificate = fromHex("3082020030820162020900b8bf2d47a0d2ebf4300906072a8648ce3d04013045310b3009060355040613024155311330110603550408130a536f6d652d53746174653121301f060355040a1318496e7465726e6574205769646769747320507479204c7464301e170d3132313132323135303633325a170d3232313132303135303633325a3045310b3009060355040613024155311330110603550408130a536f6d652d53746174653121301f060355040a1318496e7465726e6574205769646769747320507479204c746430819b301006072a8648ce3d020106052b81040023038186000400c4a1edbe98f90b4873367ec316561122f23d53c33b4d213dcd6b75e6f6b0dc9adf26c1bcb287f072327cb3642f1c90bcea6823107efee325c0483a69e0286dd33700ef0462dd0da09c706283d881d36431aa9e9731bd96b068c09b23de76643f1a5c7fe9120e5858b65f70dd9bd8ead5d7f5d5ccb9b69f30665b669a20e227e5bffe3b300906072a8648ce3d040103818c0030818802420188a24febe245c5487d1bacf5ed989dae4770c05e1bb62fbdf1b64db76140d311a2ceee0b7e927eff769dc33b7ea53fcefa10e259ec472d7cacda4e970e15a06fd00242014dfcbe67139c2d050ebd3fa38c25c13313830d9406bbd4377af6ec7ac9862eddd711697f857c56defb31782be4c7780daecbbe9e4e3624317b6a0f399512078f2a")
var testEd25519Certificate = fromHex("3082012e3081e1a00302010202100f431c425793941de987e4f1ad15005d300506032b657030123110300e060355040a130741636d6520436f301e170d3139303531363231333830315a170d3230303531353231333830315a30123110300e060355040a130741636d6520436f302a300506032b65700321003fe2152ee6e3ef3f4e854a7577a3649eede0bf842ccc92268ffa6f3483aaec8fa34d304b300e0603551d0f0101ff0404030205a030130603551d25040c300a06082b06010505070301300c0603551d130101ff0402300030160603551d11040f300d820b6578616d706c652e636f6d300506032b65700341006344ed9cc4be5324539fd2108d9fe82108909539e50dc155ff2c16b71dfcab7d4dd4e09313d0a942e0b66bfe5d6748d79f50bc6ccd4b03837cf20858cdaccf0c")
var testSNICertificate = fromHex("0441883421114c81480804c430820237308201a0a003020102020900e8f09d3fe25beaa6300d06092a864886f70d01010b0500301f310b3009060355040a1302476f3110300e06035504031307476f20526f6f74301e170d3136303130313030303030305a170d3235303130313030303030305a3023310b3009060355040a1302476f311430120603550403130b736e69746573742e636f6d30819f300d06092a864886f70d010101050003818d0030818902818100db467d932e12270648bc062821ab7ec4b6a25dfe1e5245887a3647a5080d92425bc281c0be97799840fb4f6d14fd2b138bc2a52e67d8d4099ed62238b74a0b74732bc234f1d193e596d9747bf3589f6c613cc0b041d4d92b2b2423775b1c3bbd755dce2054cfa163871d1e24c4f31d1a508baab61443ed97a77562f414c852d70203010001a3773075300e0603551d0f0101ff0404030205a0301d0603551d250416301406082b0601050507030106082b06010505070302300c0603551d130101ff0402300030190603551d0e041204109f91161f43433e49a6de6db680d79f60301b0603551d230414301280104813494d137e1631bba301d5acab6e7b300d06092a864886f70d01010b0500038181007beeecff0230dbb2e7a334af65430b7116e09f327c3bbf918107fc9c66cb497493207ae9b4dbb045cb63d605ec1b5dd485bb69124d68fa298dc776699b47632fd6d73cab57042acb26f083c4087459bc5a3bb3ca4d878d7fe31016b7bc9a627438666566e3389bfaeebe6becc9a0093ceed18d0f9ac79d56f3a73f18188988ed")
var testP256Certificate = fromHex("308201693082010ea00302010202105012dc24e1124ade4f3e153326ff27bf300a06082a8648ce3d04030230123110300e060355040a130741636d6520436f301e170d3137303533313232343934375a170d3138303533313232343934375a30123110300e060355040a130741636d6520436f3059301306072a8648ce3d020106082a8648ce3d03010703420004c02c61c9b16283bbcc14956d886d79b358aa614596975f78cece787146abf74c2d5dc578c0992b4f3c631373479ebf3892efe53d21c4f4f1cc9a11c3536b7f75a3463044300e0603551d0f0101ff0404030205a030130603551d25040c300a06082b06010505070301300c0603551d130101ff04023000300f0603551d1104083006820474657374300a06082a8648ce3d0403020349003046022100963712d6226c7b2bef41512d47e1434131aaca3ba585d666c924df71ac0448b3022100f4d05c725064741aef125f243cdbccaa2a5d485927831f221c43023bd5ae471a")
@ -588,8 +585,6 @@ var testECDSAPrivateKey, _ = x509.ParseECPrivateKey(fromHex("3081dc0201010442019
var testP256PrivateKey, _ = x509.ParseECPrivateKey(fromHex("30770201010420012f3b52bc54c36ba3577ad45034e2e8efe1e6999851284cb848725cfe029991a00a06082a8648ce3d030107a14403420004c02c61c9b16283bbcc14956d886d79b358aa614596975f78cece787146abf74c2d5dc578c0992b4f3c631373479ebf3892efe53d21c4f4f1cc9a11c3536b7f75"))
var testEd25519PrivateKey = ed25519.PrivateKey(fromHex("3a884965e76b3f55e5faf9615458a92354894234de3ec9f684d46d55cebf3dc63fe2152ee6e3ef3f4e854a7577a3649eede0bf842ccc92268ffa6f3483aaec8f"))
const clientCertificatePEM = `
-----BEGIN CERTIFICATE-----
MIIB7zCCAVigAwIBAgIQXBnBiWWDVW/cC8m5k5/pvDANBgkqhkiG9w0BAQsFADAS

View file

@ -1197,19 +1197,19 @@ func TestConnectionStateMarshal(t *testing.T) {
}
func TestConnectionState(t *testing.T) {
issuer, err := x509.ParseCertificate(testRSA2048CertificateIssuer)
if err != nil {
panic(err)
}
rootCAs := x509.NewCertPool()
rootCAs.AddCert(issuer)
const alpnProtocol = "golang"
const serverName = "example.golang"
const serverName = "test.golang.example"
var scts = [][]byte{[]byte("dummy sct 1"), []byte("dummy sct 2")}
var ocsp = []byte("dummy ocsp")
checkConnectionState := func(t *testing.T, cs ConnectionState, version uint16, isClient bool) {
// On the client, the peer is the server (testRSA2048Cert under
// testRootCert); on the server, the peer is the client
// (testClientRSA2048Cert under testClientRootCert).
peerLeaf, peerRoot := testRSA2048Cert.Certificate[0], testRootCert.Certificate[0]
if !isClient {
peerLeaf, peerRoot = testClientRSA2048Cert.Certificate[0], testClientRootCert.Certificate[0]
}
if cs.Version != version {
t.Errorf("got Version %x, expected %x", cs.Version, version)
}
@ -1244,18 +1244,18 @@ func TestConnectionState(t *testing.T) {
if len(cs.PeerCertificates) != 1 {
t.Errorf("got %d PeerCertificates, expected %d", len(cs.PeerCertificates), 1)
} else if !bytes.Equal(cs.PeerCertificates[0].Raw, testRSA2048Certificate) {
t.Errorf("got PeerCertificates %x, expected %x", cs.PeerCertificates[0].Raw, testRSA2048Certificate)
} else if !bytes.Equal(cs.PeerCertificates[0].Raw, peerLeaf) {
t.Errorf("got PeerCertificates %x, expected %x", cs.PeerCertificates[0].Raw, peerLeaf)
}
if len(cs.VerifiedChains) != 1 {
t.Errorf("got %d long verified chain, expected %d", len(cs.VerifiedChains), 1)
} else if len(cs.VerifiedChains[0]) != 2 {
t.Errorf("got %d verified chain, expected %d", len(cs.VerifiedChains[0]), 2)
} else if !bytes.Equal(cs.VerifiedChains[0][0].Raw, testRSA2048Certificate) {
t.Errorf("got verified chain[0][0] %x, expected %x", cs.VerifiedChains[0][0].Raw, testRSA2048Certificate)
} else if !bytes.Equal(cs.VerifiedChains[0][1].Raw, testRSA2048CertificateIssuer) {
t.Errorf("got verified chain[0][1] %x, expected %x", cs.VerifiedChains[0][1].Raw, testRSA2048CertificateIssuer)
} else if !bytes.Equal(cs.VerifiedChains[0][0].Raw, peerLeaf) {
t.Errorf("got verified chain[0][0] %x, expected %x", cs.VerifiedChains[0][0].Raw, peerLeaf)
} else if !bytes.Equal(cs.VerifiedChains[0][1].Raw, peerRoot) {
t.Errorf("got verified chain[0][1] %x, expected %x", cs.VerifiedChains[0][1].Raw, peerRoot)
}
// Only TLS 1.3 supports OCSP and SCTs on client certs.
@ -1342,24 +1342,34 @@ func TestConnectionState(t *testing.T) {
name = "TLSv13"
}
t.Run(name, func(t *testing.T) {
config := &Config{
serverCert := testRSA2048Cert
serverCert.SignedCertificateTimestamps = scts
serverCert.OCSPStaple = ocsp
clientCert := testClientRSA2048Cert
clientCert.SignedCertificateTimestamps = scts
clientCert.OCSPStaple = ocsp
serverConfig := &Config{
Time: testTime,
Certificates: []Certificate{serverCert},
MinVersion: v,
MaxVersion: v,
ClientCAs: testClientRootCertPool,
ClientAuth: RequireAndVerifyClientCert,
NextProtos: []string{alpnProtocol},
}
clientConfig := &Config{
Time: testTime,
Certificates: make([]Certificate, 1),
Certificates: []Certificate{clientCert},
MinVersion: v,
MaxVersion: v,
RootCAs: rootCAs,
ClientCAs: rootCAs,
ClientAuth: RequireAndVerifyClientCert,
RootCAs: testRootCertPool,
NextProtos: []string{alpnProtocol},
ServerName: serverName,
ClientSessionCache: NewLRUClientSessionCache(1),
}
config.Certificates[0].Certificate = [][]byte{testRSA2048Certificate}
config.Certificates[0].PrivateKey = testRSA2048PrivateKey
config.Certificates[0].SignedCertificateTimestamps = scts
config.Certificates[0].OCSPStaple = ocsp
ss, cs, err := testHandshake(t, config, config)
ss, cs, err := testHandshake(t, clientConfig, serverConfig)
if err != nil {
t.Fatalf("handshake failed: %v", err)
}
@ -1371,7 +1381,7 @@ func TestConnectionState(t *testing.T) {
// TODO: test changing parameters between original and resumed
// connection when the protocol allows it.
ss1, cs1, err := testHandshake(t, config, config)
ss1, cs1, err := testHandshake(t, clientConfig, serverConfig)
if err != nil {
t.Fatalf("handshake failed: %v", err)
}
@ -1390,20 +1400,12 @@ func TestConnectionState(t *testing.T) {
// Issue 28744: Ensure that we don't modify memory
// that Config doesn't own such as Certificates.
func TestBuildNameToCertificate_doesntModifyCertificates(t *testing.T) {
c0 := Certificate{
Certificate: [][]byte{testRSACertificate},
PrivateKey: testRSAPrivateKey,
}
c1 := Certificate{
Certificate: [][]byte{testSNICertificate},
PrivateKey: testRSAPrivateKey,
}
config := testConfig.Clone()
config.Certificates = []Certificate{c0, c1}
config.Certificates = []Certificate{testRSA2048Cert, testSNICert}
config.BuildNameToCertificate()
got := config.Certificates
want := []Certificate{c0, c1}
want := []Certificate{testRSA2048Cert, testSNICert}
if !reflect.DeepEqual(got, want) {
t.Fatalf("Certificates were mutated by BuildNameToCertificate\nGot: %#v\nWant: %#v\n", got, want)
}
@ -1414,45 +1416,29 @@ func testingKey(s string) string { return strings.ReplaceAll(s, "TESTING KEY", "
func TestClientHelloInfo_SupportsCertificate(t *testing.T) {
skipFIPS(t) // Test certificates not FIPS compatible.
rsaCert := &Certificate{
Certificate: [][]byte{testRSACertificate},
PrivateKey: testRSAPrivateKey,
}
pkcs1Cert := &Certificate{
Certificate: [][]byte{testRSACertificate},
PrivateKey: testRSAPrivateKey,
SupportedSignatureAlgorithms: []SignatureScheme{PKCS1WithSHA1, PKCS1WithSHA256},
}
ecdsaCert := &Certificate{
// ECDSA P-256 certificate
Certificate: [][]byte{testP256Certificate},
PrivateKey: testP256PrivateKey,
}
ed25519Cert := &Certificate{
Certificate: [][]byte{testEd25519Certificate},
PrivateKey: testEd25519PrivateKey,
}
pkcs1Cert := testRSA2048Cert
pkcs1Cert.SupportedSignatureAlgorithms = []SignatureScheme{PKCS1WithSHA1, PKCS1WithSHA256}
tests := []struct {
c *Certificate
c Certificate
chi *ClientHelloInfo
wantErr string
}{
{rsaCert, &ClientHelloInfo{
ServerName: "example.golang",
{testRSA2048Cert, &ClientHelloInfo{
ServerName: "test.golang.example",
SignatureSchemes: []SignatureScheme{PSSWithSHA256},
SupportedVersions: []uint16{VersionTLS13},
}, ""},
{ecdsaCert, &ClientHelloInfo{
{testECDSAP256Cert, &ClientHelloInfo{
SignatureSchemes: []SignatureScheme{PSSWithSHA256, ECDSAWithP256AndSHA256},
SupportedVersions: []uint16{VersionTLS13, VersionTLS12},
}, ""},
{rsaCert, &ClientHelloInfo{
{testRSA2048Cert, &ClientHelloInfo{
ServerName: "example.com",
SignatureSchemes: []SignatureScheme{PSSWithSHA256},
SupportedVersions: []uint16{VersionTLS13},
}, "not valid for requested server name"},
{ecdsaCert, &ClientHelloInfo{
{testECDSAP256Cert, &ClientHelloInfo{
SignatureSchemes: []SignatureScheme{ECDSAWithP384AndSHA384},
SupportedVersions: []uint16{VersionTLS13},
}, "signature algorithms"},
@ -1461,12 +1447,12 @@ func TestClientHelloInfo_SupportsCertificate(t *testing.T) {
SupportedVersions: []uint16{VersionTLS13},
}, "signature algorithms"},
{rsaCert, &ClientHelloInfo{
{testRSA2048Cert, &ClientHelloInfo{
CipherSuites: []uint16{TLS_RSA_WITH_AES_128_GCM_SHA256},
SignatureSchemes: []SignatureScheme{PKCS1WithSHA1},
SupportedVersions: []uint16{VersionTLS13, VersionTLS12},
}, "signature algorithms"},
{rsaCert, &ClientHelloInfo{
{testRSA2048Cert, &ClientHelloInfo{
CipherSuites: []uint16{TLS_RSA_WITH_AES_128_GCM_SHA256},
SignatureSchemes: []SignatureScheme{PKCS1WithSHA1},
SupportedVersions: []uint16{VersionTLS13, VersionTLS12},
@ -1476,35 +1462,35 @@ func TestClientHelloInfo_SupportsCertificate(t *testing.T) {
},
}, ""}, // Check that mutual version selection works.
{ecdsaCert, &ClientHelloInfo{
{testECDSAP256Cert, &ClientHelloInfo{
CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256},
SupportedCurves: []CurveID{CurveP256},
SupportedPoints: []uint8{pointFormatUncompressed},
SignatureSchemes: []SignatureScheme{ECDSAWithP256AndSHA256},
SupportedVersions: []uint16{VersionTLS12},
}, ""},
{ecdsaCert, &ClientHelloInfo{
{testECDSAP256Cert, &ClientHelloInfo{
CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256},
SupportedCurves: []CurveID{CurveP256},
SupportedPoints: []uint8{pointFormatUncompressed},
SignatureSchemes: []SignatureScheme{ECDSAWithP384AndSHA384},
SupportedVersions: []uint16{VersionTLS12},
}, ""}, // TLS 1.2 does not restrict curves based on the SignatureScheme.
{ecdsaCert, &ClientHelloInfo{
{testECDSAP256Cert, &ClientHelloInfo{
CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256},
SupportedCurves: []CurveID{CurveP256},
SupportedPoints: []uint8{pointFormatUncompressed},
SignatureSchemes: nil,
SupportedVersions: []uint16{VersionTLS12},
}, ""}, // TLS 1.2 comes with default signature schemes.
{ecdsaCert, &ClientHelloInfo{
{testECDSAP256Cert, &ClientHelloInfo{
CipherSuites: []uint16{TLS_RSA_WITH_AES_128_GCM_SHA256},
SupportedCurves: []CurveID{CurveP256},
SupportedPoints: []uint8{pointFormatUncompressed},
SignatureSchemes: []SignatureScheme{ECDSAWithP256AndSHA256},
SupportedVersions: []uint16{VersionTLS12},
}, "cipher suite"},
{ecdsaCert, &ClientHelloInfo{
{testECDSAP256Cert, &ClientHelloInfo{
CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256},
SupportedCurves: []CurveID{CurveP256},
SupportedPoints: []uint8{pointFormatUncompressed},
@ -1514,21 +1500,21 @@ func TestClientHelloInfo_SupportsCertificate(t *testing.T) {
CipherSuites: []uint16{TLS_RSA_WITH_AES_128_GCM_SHA256},
},
}, "cipher suite"},
{ecdsaCert, &ClientHelloInfo{
{testECDSAP256Cert, &ClientHelloInfo{
CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256},
SupportedCurves: []CurveID{CurveP384},
SupportedPoints: []uint8{pointFormatUncompressed},
SignatureSchemes: []SignatureScheme{ECDSAWithP256AndSHA256},
SupportedVersions: []uint16{VersionTLS12},
}, "certificate curve"},
{ecdsaCert, &ClientHelloInfo{
{testECDSAP256Cert, &ClientHelloInfo{
CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256},
SupportedCurves: []CurveID{CurveP256},
SupportedPoints: []uint8{1},
SignatureSchemes: []SignatureScheme{ECDSAWithP256AndSHA256},
SupportedVersions: []uint16{VersionTLS12},
}, "only incompatible point formats"},
{ecdsaCert, &ClientHelloInfo{
{testECDSAP256Cert, &ClientHelloInfo{
CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256},
SupportedCurves: []CurveID{CurveP256},
SupportedPoints: []uint8{pointFormatUncompressed},
@ -1536,14 +1522,14 @@ func TestClientHelloInfo_SupportsCertificate(t *testing.T) {
SupportedVersions: []uint16{VersionTLS12},
}, "signature algorithms"},
{ed25519Cert, &ClientHelloInfo{
{testEd25519Cert, &ClientHelloInfo{
CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256},
SupportedCurves: []CurveID{CurveP256}, // only relevant for ECDHE support
SupportedPoints: []uint8{pointFormatUncompressed},
SignatureSchemes: []SignatureScheme{Ed25519},
SupportedVersions: []uint16{VersionTLS12},
}, ""},
{ed25519Cert, &ClientHelloInfo{
{testEd25519Cert, &ClientHelloInfo{
CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256},
SupportedCurves: []CurveID{CurveP256}, // only relevant for ECDHE support
SupportedPoints: []uint8{pointFormatUncompressed},
@ -1551,7 +1537,7 @@ func TestClientHelloInfo_SupportsCertificate(t *testing.T) {
SupportedVersions: []uint16{VersionTLS10},
config: &Config{MinVersion: VersionTLS10},
}, "doesn't support Ed25519"},
{ed25519Cert, &ClientHelloInfo{
{testEd25519Cert, &ClientHelloInfo{
CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256},
SupportedCurves: []CurveID{},
SupportedPoints: []uint8{pointFormatUncompressed},
@ -1559,14 +1545,14 @@ func TestClientHelloInfo_SupportsCertificate(t *testing.T) {
SupportedVersions: []uint16{VersionTLS12},
}, "doesn't support ECDHE"},
{rsaCert, &ClientHelloInfo{
{testRSA2048Cert, &ClientHelloInfo{
CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA},
SupportedCurves: []CurveID{CurveP256}, // only relevant for ECDHE support
SupportedPoints: []uint8{pointFormatUncompressed},
SupportedVersions: []uint16{VersionTLS10},
config: &Config{MinVersion: VersionTLS10},
}, ""},
{rsaCert, &ClientHelloInfo{
{testRSA2048Cert, &ClientHelloInfo{
CipherSuites: []uint16{TLS_RSA_WITH_AES_128_GCM_SHA256},
SupportedVersions: []uint16{VersionTLS12},
config: &Config{
@ -1575,7 +1561,7 @@ func TestClientHelloInfo_SupportsCertificate(t *testing.T) {
}, ""}, // static RSA fallback
}
for i, tt := range tests {
err := tt.chi.SupportsCertificate(tt.c)
err := tt.chi.SupportsCertificate(&tt.c)
switch {
case tt.wantErr == "" && err != nil:
t.Errorf("%d: unexpected error: %v", i, err)
@ -1840,8 +1826,8 @@ func (s brokenSigner) Sign(rand io.Reader, digest []byte, opts crypto.SignerOpts
func TestPKCS1OnlyCert(t *testing.T) {
clientConfig := testConfig.Clone()
clientConfig.Certificates = []Certificate{{
Certificate: [][]byte{testRSACertificate},
PrivateKey: brokenSigner{testRSAPrivateKey},
Certificate: testRSA2048Cert.Certificate,
PrivateKey: brokenSigner{testRSA2048Key},
}}
serverConfig := testConfig.Clone()
serverConfig.MaxVersion = VersionTLS12 // TLS 1.3 doesn't support PKCS #1 v1.5
@ -2465,12 +2451,12 @@ func testMessageSigner(t *testing.T, version uint16) {
serverConfig.MinVersion = version
serverConfig.MaxVersion = version
clientConfig.Certificates = []Certificate{{
Certificate: [][]byte{testRSACertificate},
PrivateKey: messageOnlySigner{testRSAPrivateKey},
Certificate: testRSA2048Cert.Certificate,
PrivateKey: messageOnlySigner{testRSA2048Key},
}}
serverConfig.Certificates = []Certificate{{
Certificate: [][]byte{testRSACertificate},
PrivateKey: messageOnlySigner{testRSAPrivateKey},
Certificate: testRSA2048Cert.Certificate,
PrivateKey: messageOnlySigner{testRSA2048Key},
}}
_, _, err := testHandshake(t, clientConfig, serverConfig)
@ -2485,12 +2471,12 @@ func testMessageSigner(t *testing.T, version uint16) {
}
clientConfig.Certificates = []Certificate{{
Certificate: [][]byte{testECDSACertificate},
PrivateKey: messageOnlySigner{testECDSAPrivateKey},
Certificate: testECDSAP256Cert.Certificate,
PrivateKey: messageOnlySigner{testECDSAP256Key},
}}
serverConfig.Certificates = []Certificate{{
Certificate: [][]byte{testECDSACertificate},
PrivateKey: messageOnlySigner{testECDSAPrivateKey},
Certificate: testECDSAP256Cert.Certificate,
PrivateKey: messageOnlySigner{testECDSAP256Key},
}}
_, _, err = testHandshake(t, clientConfig, serverConfig)