Created
September 29, 2017 01:58
-
-
Save xigang/f1bb7279f6802c160b1c49d4b1d0808a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func createClientConfig(ca, crt, key string) (*tls.Config, error) { | |
caCertPEM, err := ioutil.ReadFile(ca) | |
if err != nil { | |
return nil, err | |
} | |
roots := x509.NewCertPool() | |
ok := roots.AppendCertsFromPEM(caCertPEM) | |
if !ok { | |
panic("failed to parse root certificate") | |
} | |
cert, err := tls.LoadX509KeyPair(crt, key) | |
if err != nil { | |
return nil, err | |
} | |
return &tls.Config{ | |
Certificates: []tls.Certificate{cert}, | |
RootCAs: roots, | |
InsecureSkipVerify: true, | |
}, nil | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment