我项目中grpc需要对证书进行验证,使用x509,但是线上服务器openssl的版本太低0.9.7,并且线上服务器使用了集群,会不定时的进行迁移项目,所以升级线上服务器的openssl版本无法实现,现在我想的是在项目中自定义一个高版本的openssl,然后x509解析证书时使用自定义的高版本,但是我查看对应的package,没有找到添加自定义openssl的地方,问一下大家有什么方法可以让我的x509使用高版本openssl?
var certFile, _ = filepath.Abs("conf/pem/ser.pem")
var keyFile, _ = filepath.Abs("conf/pem/ser.auto_key")
var client_ca, _ = filepath.Abs("conf/pem/ca.pem")
var opts []grpc.ServerOption
certificate, err := tls.LoadX509KeyPair(
certFile,
keyFile,
)
certPool := x509.NewCertPool()
bs, err := ioutil.ReadFile(client_ca)
if err != nil {
log.Fatalf("failed to read client ca cert: %s", err)
}
ok := certPool.AppendCertsFromPEM(bs)
if !ok {
log.Fatal("failed to append client certs")
}
tlsConfig := &tls.Config{
ClientAuth: tls.RequireAndVerifyClientCert,
Certificates: []tls.Certificate{certificate},
ClientCAs: certPool,
}
serverOption := grpc.Creds(credentials.NewTLS(tlsConfig))
opts = []grpc.ServerOption{serverOption}
s := grpc.NewServer(opts...)
相似问题