|
|
@@ -156,7 +156,7 @@ func TestTLSCertificateVerification(t *testing.T) {
|
|
|
t.Errorf("unexpected success without invalid pin")
|
|
|
}
|
|
|
|
|
|
- // Test: with the root CA certirficate pinned, the TLS dial succeeds.
|
|
|
+ // Test: with the root CA certificate pinned, the TLS dial succeeds.
|
|
|
|
|
|
conn, err = CustomTLSDial(
|
|
|
context.Background(), "tcp", serverAddr,
|
|
|
@@ -209,6 +209,27 @@ func TestTLSCertificateVerification(t *testing.T) {
|
|
|
} else {
|
|
|
conn.Close()
|
|
|
}
|
|
|
+
|
|
|
+ // Test: with SNI changed, DisableSystemRootCAs set along with
|
|
|
+ // VerifyServerName and VerifyPins, and pinning the TLS dial
|
|
|
+ // succeeds.
|
|
|
+
|
|
|
+ conn, err = CustomTLSDial(
|
|
|
+ context.Background(), "tcp", serverAddr,
|
|
|
+ &CustomTLSConfig{
|
|
|
+ Parameters: params,
|
|
|
+ Dial: dialer,
|
|
|
+ SNIServerName: "not-" + serverName,
|
|
|
+ DisableSystemRootCAs: true,
|
|
|
+ VerifyServerName: serverName,
|
|
|
+ VerifyPins: []string{rootCACertificatePin},
|
|
|
+ })
|
|
|
+
|
|
|
+ if err != nil {
|
|
|
+ t.Errorf("CustomTLSDial failed: %v", err)
|
|
|
+ } else {
|
|
|
+ conn.Close()
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// initTestCertificatesAndWebServer creates a Root CA, a web server
|
|
|
@@ -337,7 +358,7 @@ func initTestCertificatesAndWebServer(
|
|
|
// Run an HTTPS server with the server certificate.
|
|
|
|
|
|
serverKeyPair, err := tls.X509KeyPair(
|
|
|
- pemServerCertificate, pemServerPrivateKey)
|
|
|
+ append(pemServerCertificate, pemRootCACertificate...), pemServerPrivateKey)
|
|
|
if err != nil {
|
|
|
t.Fatalf("tls.X509KeyPair failed: %v", err)
|
|
|
}
|