feat: support tls for etcd client (#1390)
* feat: support tls for etcd client * chore: fix typo * refactor: rename TrustedCAFile to CACertFile * docs: add comments * fix: missing tls registration * feat: add InsecureSkipVerify config for testing
This commit is contained in:
@@ -83,6 +83,12 @@ func (cc RpcClientConf) BuildTarget() (string, error) {
|
||||
if cc.Etcd.HasAccount() {
|
||||
discov.RegisterAccount(cc.Etcd.Hosts, cc.Etcd.User, cc.Etcd.Pass)
|
||||
}
|
||||
if cc.Etcd.HasTLS() {
|
||||
if err := discov.RegisterTLS(cc.Etcd.Hosts, cc.Etcd.CertFile, cc.Etcd.CertKeyFile,
|
||||
cc.Etcd.CACertFile, cc.Etcd.InsecureSkipVerify); err != nil {
|
||||
return "", err
|
||||
}
|
||||
}
|
||||
|
||||
return resolver.BuildDiscovTarget(cc.Etcd.Hosts, cc.Etcd.Key), nil
|
||||
}
|
||||
|
||||
@@ -21,6 +21,10 @@ func NewRpcPubServer(etcd discov.EtcdConf, listenOn string, opts ...ServerOption
|
||||
if etcd.HasAccount() {
|
||||
pubOpts = append(pubOpts, discov.WithPubEtcdAccount(etcd.User, etcd.Pass))
|
||||
}
|
||||
if etcd.HasTLS() {
|
||||
pubOpts = append(pubOpts, discov.WithPubEtcdTLS(etcd.CertFile, etcd.CertKeyFile,
|
||||
etcd.CACertFile, etcd.InsecureSkipVerify))
|
||||
}
|
||||
pubClient := discov.NewPublisher(etcd.Hosts, etcd.Key, pubListenOn, pubOpts...)
|
||||
return pubClient.KeepAlive()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user