Created
January 22, 2019 23:35
-
-
Save tychoish/c0eb005aa7eec64500611728d8412883 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 NewClientTLSFromFile(certFile, serverNameOverride string) (TransportCredentials, error) { | |
b, err := ioutil.ReadFile(certFile) | |
if err != nil { | |
return nil, err | |
} | |
cp := x509.NewCertPool() | |
if !cp.AppendCertsFromPEM(b) { | |
return nil, fmt.Errorf("credentials: failed to append certificates") | |
} | |
return NewTLS(&tls.Config{ServerName: serverNameOverride, RootCAs: cp}), nil | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment