Skip to content

Commit

Permalink
speed up TestMTLSClientCAs
Browse files Browse the repository at this point in the history
  • Loading branch information
nklaassen committed Jun 20, 2024
1 parent b58f7f6 commit 0cb7701
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions lib/kube/proxy/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,9 @@ import (
"crypto/ecdsa"
"crypto/elliptic"
"crypto/rand"
"crypto/rsa"
"crypto/tls"
"crypto/x509"
"crypto/x509/pkix"
"encoding/pem"
"errors"
"fmt"
"net"
Expand Down Expand Up @@ -66,7 +64,7 @@ func TestMTLSClientCAs(t *testing.T) {
cas: make(map[string]types.CertAuthority),
}
// Reuse the same CA private key for performance.
caKey, err := rsa.GenerateKey(rand.Reader, 2048)
caKey, err := ecdsa.GenerateKey(elliptic.P256(), rand.Reader)
require.NoError(t, err)

addCA := func(t *testing.T, name string) (key, cert []byte) {
Expand Down Expand Up @@ -105,9 +103,8 @@ func TestMTLSClientCAs(t *testing.T) {
DNSNames: sans,
})
require.NoError(t, err)
keyRaw, err := x509.MarshalECPrivateKey(userHostKey)
keyPEM, err := keys.MarshalPrivateKey(userHostKey)
require.NoError(t, err)
keyPEM := pem.EncodeToMemory(&pem.Block{Type: "PRIVATE KEY", Bytes: keyRaw})
cert, err := tls.X509KeyPair(certRaw, keyPEM)
require.NoError(t, err)
return cert
Expand Down

0 comments on commit 0cb7701

Please sign in to comment.