mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
Merge pull request #8300 from heyitsanthony/proxy-self-cert
etcdmain: create self-signed certs when listening on https for httpproxy
This commit is contained in:
commit
986e98418d
@ -314,9 +314,28 @@ func startProxy(cfg *config) error {
|
|||||||
if cfg.isReadonlyProxy() {
|
if cfg.isReadonlyProxy() {
|
||||||
ph = httpproxy.NewReadonlyHandler(ph)
|
ph = httpproxy.NewReadonlyHandler(ph)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// setup self signed certs when serving https
|
||||||
|
cHosts, cTLS := []string{}, false
|
||||||
|
for _, u := range cfg.LCUrls {
|
||||||
|
cHosts = append(cHosts, u.Host)
|
||||||
|
cTLS = cTLS || u.Scheme == "https"
|
||||||
|
}
|
||||||
|
for _, u := range cfg.ACUrls {
|
||||||
|
cHosts = append(cHosts, u.Host)
|
||||||
|
cTLS = cTLS || u.Scheme == "https"
|
||||||
|
}
|
||||||
|
listenerTLS := cfg.ClientTLSInfo
|
||||||
|
if cfg.ClientAutoTLS && cTLS {
|
||||||
|
listenerTLS, err = transport.SelfCert(filepath.Join(cfg.Dir, "clientCerts"), cHosts)
|
||||||
|
if err != nil {
|
||||||
|
plog.Fatalf("proxy: could not initialize self-signed client certs (%v)", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Start a proxy server goroutine for each listen address
|
// Start a proxy server goroutine for each listen address
|
||||||
for _, u := range cfg.LCUrls {
|
for _, u := range cfg.LCUrls {
|
||||||
l, err := transport.NewListener(u.Host, u.Scheme, &cfg.ClientTLSInfo)
|
l, err := transport.NewListener(u.Host, u.Scheme, &listenerTLS)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user