summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--regress/lib/libtls/gotls/tls_test.go64
1 files changed, 63 insertions, 1 deletions
diff --git a/regress/lib/libtls/gotls/tls_test.go b/regress/lib/libtls/gotls/tls_test.go
index be880e138c7..f6c6cfcdd52 100644
--- a/regress/lib/libtls/gotls/tls_test.go
+++ b/regress/lib/libtls/gotls/tls_test.go
@@ -17,12 +17,64 @@ import (
const (
httpContent = "Hello, TLS!"
- certHash = "SHA256:448f628a8a65aa18560e53a80c53acb38c51b427df0334082349141147dc9bf6"
+ certHash = "SHA256:1153aa0230ee0481b36bdd83ddb04b607340dbda35f3a4fff0615e4d9292d687"
)
var (
certNotBefore = time.Unix(0, 0)
certNotAfter = certNotBefore.Add(1000000 * time.Hour)
+
+ // Generated with:
+ // go run crypto/tls/generate_cert.go --rsa-bits 2048 \
+ // --host 127.0.0.1,::1,example.com --ca \
+ // --start-date "Jan 1 00:00:00 1970" --duration=1000000h`
+ testServerCert = []byte(`-----BEGIN CERTIFICATE-----
+MIIDGTCCAgGgAwIBAgIRAJHZkrBTk/yTKT3L2Z+dgZcwDQYJKoZIhvcNAQELBQAw
+EjEQMA4GA1UEChMHQWNtZSBDbzAgFw03MDAxMDEwMDAwMDBaGA8yMDg0MDEyOTE2
+MDAwMFowEjEQMA4GA1UEChMHQWNtZSBDbzCCASIwDQYJKoZIhvcNAQEBBQADggEP
+ADCCAQoCggEBANxPCe2pafj2pWdA+hnN+Ne9Auh2YdoSPbQqIPQMVTT/3j6w9LlW
+JirXCLWNuoarOA2iCgVa4Y607O/f2FTN7cKY2lvhAkuftCUJzB/lJVH5bWZgSrks
+3AaOBlBcyMKBajFoEOIgSMwHGAZO2XsWIvdbuQw3EKY50vfBvxQspjbMruhpZoKd
+9tHx6XUBoYSf5t9X+FrG2UjihnfcfBcsKGq7lbujt3+3QvlU6w1ZGOX+f9b+3+yw
+RQkswxvkzKpfmgvr8GWWUm8w9wkImhAmA2UAhsM8OwnKVltvMih5m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5MCAgzD9X/Tx2OvOqgWnSXt2Q2AhK2UsHnrGBn1SDNTNDGlniQy2OM2Ywn
+n71nH1QUmgoiwBrFUh0gLxv878vwgUATqfFRTlirmK9XxHuTX9Jh6elmRebjYWyc
+Oo0CJBeMABu71Y+VkCxURT1bzw==
+-----END PRIVATE KEY-----`)
)
type handshakeError string
@@ -57,6 +109,16 @@ func newTestServer(tlsCfg *tls.Config) (*httptest.Server, *url.URL, string, erro
},
),
)
+ if tlsCfg == nil {
+ tlsCfg = &tls.Config{}
+ }
+ if len(tlsCfg.Certificates) == 0 {
+ cert, err := tls.X509KeyPair(testServerCert, testServerKey)
+ if err != nil {
+ return nil, nil, "", fmt.Errorf("failed to load key pair: %v", err)
+ }
+ tlsCfg.Certificates = []tls.Certificate{cert}
+ }
ts.TLS = tlsCfg
ts.StartTLS()