This is trying to implement a 2 way ssl connection. I have been fighting this for a week and it seems my go (1.5.3) code problem.
The attached certFile, keyFile, and caFile have been tested with nginx and curl. They work fine. And yes, the CA file are locally generated.
cert, _ := tls.LoadX509KeyPair(certFile, keyFile)
// Load CA cert
caCert, _ := ioutil.ReadFile(caFile)
caCertPool := x509.NewCertPool()
caCertPool.AppendCertsFromPEM(caCert)
// Create tls config
tlsConfig := &tls.Config{
Certificates: []tls.Certificate{cert},
RootCAs: caCertPool,
ClientAuth: tls.RequireAndVerifyClientCert, // server side setting
InsecureSkipVerify: false, // client side setting
}
tlsConfig.BuildNameToCertificate()
listener, err = tls.Listen("tcp", listenOn, tlsConfig) http.Serve(listener, masterMux)