added etcd support

This commit is contained in:
ston1th 2020-11-15 18:39:16 +01:00
commit 85a8ba23bd
21 changed files with 767 additions and 247 deletions

View file

@ -3,7 +3,6 @@ package tls
import (
"crypto/tls"
"crypto/x509"
"io/ioutil"
"net"
"time"
@ -20,19 +19,6 @@ var (
}
)
func loadCertPool(file string) (p *x509.CertPool, err error) {
if file == "" {
return
}
buf, err := ioutil.ReadFile(file)
if err != nil {
return
}
p = x509.NewCertPool()
p.AppendCertsFromPEM(buf)
return
}
type stream struct {
net.Listener
insecure bool
@ -44,7 +30,7 @@ func NewStream(cfg *config.Raft) (s *stream, err error) {
if err != nil {
return
}
ca, err := loadCertPool(cfg.TLS.CA)
ca, err := config.LoadCertPool(cfg.TLS.CA)
if err != nil {
return
}