We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
我想实现客户也有证书,服务器要验证客户端的证书;我在客户端加了证书 服务端做了验证 客户端访问不到 也没有错误; 下面是我的代码;我这样写有问题吗 客户端: d, err3 := etcd_client.NewEtcdV3Discovery(*basePath1, *serverName, []string{*etcdAddr1}, false, nil) if err3 != nil { log.Panicln("err3:", err3) } //conf := &tls.Config{ // InsecureSkipVerify: true, //} //加入tls cert, err := tls.LoadX509KeyPair("../tls/client.crt", "../tls/client.key") if err != nil { log.Fatal("err:", err) } certPool := x509.NewCertPool() certBytes, eeee := ioutil.ReadFile("../tls/client.crt") if eeee != nil { panic("eeeee") } if !certPool.AppendCertsFromPEM(certBytes) { panic("cc") } confls := &tls.Config{ Certificates: []tls.Certificate{cert}, RootCAs: certPool, }
option := client.DefaultOption option.TLSConfig = confls xclient := client.NewXClient(*serverName, client.Failover, client.RoundRobin, d, option) defer xclient.Close()
服务端: cert, err := tls.LoadX509KeyPair("tls/server.crt", "tls/server.key") if err != nil { log.Panicln("tls red err:", err) } certPool := x509.NewCertPool()
certBytes, err := ioutil.ReadFile("tls/client.crt") if err != nil { log.Panicln("errrrrrrr:", err) } certPool.AppendCertsFromPEM(certBytes) //lstconfig := &tls.Config{Certificates: []tls.Certificate{cert}} lstconfig := &tls.Config{ ClientCAs: certPool, ClientAuth: tls.RequireAndVerifyClientCert, Certificates: []tls.Certificate{cert}, } //实例化user服务的结构体 ctx := svc.NewServicContext(conf) svr := servic.NewUserServer(ctx) s := server.NewServer(server.WithTLSConfig(lstconfig))
The text was updated successfully, but these errors were encountered:
No branches or pull requests
我想实现客户也有证书,服务器要验证客户端的证书;我在客户端加了证书 服务端做了验证 客户端访问不到 也没有错误;
下面是我的代码;我这样写有问题吗
客户端:
d, err3 := etcd_client.NewEtcdV3Discovery(*basePath1, *serverName, []string{*etcdAddr1}, false, nil)
if err3 != nil {
log.Panicln("err3:", err3)
}
//conf := &tls.Config{
// InsecureSkipVerify: true,
//}
//加入tls
cert, err := tls.LoadX509KeyPair("../tls/client.crt", "../tls/client.key")
if err != nil {
log.Fatal("err:", err)
}
certPool := x509.NewCertPool()
certBytes, eeee := ioutil.ReadFile("../tls/client.crt")
if eeee != nil {
panic("eeeee")
}
if !certPool.AppendCertsFromPEM(certBytes) {
panic("cc")
}
confls := &tls.Config{
Certificates: []tls.Certificate{cert},
RootCAs: certPool,
}
服务端:
cert, err := tls.LoadX509KeyPair("tls/server.crt", "tls/server.key")
if err != nil {
log.Panicln("tls red err:", err)
}
certPool := x509.NewCertPool()
The text was updated successfully, but these errors were encountered: