@@ -40,7 +40,7 @@ import (
4040)
4141
4242func TestMakeVerifyServerConnection (t * testing.T ) {
43- testCerts := genTestCerts (t )
43+ testCerts := GenTestCerts (t )
4444
4545 certPool := x509 .NewCertPool ()
4646 certPool .AddCert (testCerts ["ca" ])
@@ -192,13 +192,13 @@ func TestMakeVerifyServerConnection(t *testing.T) {
192192}
193193
194194func TestTrustRootCA (t * testing.T ) {
195- certs := genTestCerts (t )
195+ certs := GenTestCerts (t )
196196
197197 nonEmptyCertPool := x509 .NewCertPool ()
198198 nonEmptyCertPool .AddCert (certs ["wildcard" ])
199199 nonEmptyCertPool .AddCert (certs ["unknown_authority" ])
200200
201- fingerprint := getFingerprint (certs ["ca" ])
201+ fingerprint := GetCertFingerprint (certs ["ca" ])
202202
203203 testCases := []struct {
204204 name string
@@ -267,8 +267,8 @@ func TestTrustRootCA(t *testing.T) {
267267}
268268
269269func TestMakeVerifyConnectionUsesCATrustedFingerprint (t * testing.T ) {
270- testCerts := genTestCerts (t )
271- fingerprint := getFingerprint (testCerts ["ca" ])
270+ testCerts := GenTestCerts (t )
271+ fingerprint := GetCertFingerprint (testCerts ["ca" ])
272272
273273 testcases := map [string ]struct {
274274 verificationMode TLSVerificationMode
@@ -684,12 +684,14 @@ func startTestServer(t *testing.T, serverAddr string, serverCerts []tls.Certific
684684 return * serverURL
685685}
686686
687- func getFingerprint (cert * x509.Certificate ) string {
687+ // GetCertFingerPrint takes a certificate and returns its HEX encoded SHA-256
688+ func GetCertFingerprint (cert * x509.Certificate ) string {
688689 caSHA256 := sha256 .Sum256 (cert .Raw )
689690 return hex .EncodeToString (caSHA256 [:])
690691}
691692
692- func genTestCerts (t * testing.T ) map [string ]* x509.Certificate {
693+ func GenTestCerts (t * testing.T ) map [string ]* x509.Certificate {
694+ t .Helper ()
693695 ca , err := genCA ()
694696 if err != nil {
695697 t .Fatalf ("cannot generate root CA: %s" , err )
0 commit comments