Browse Source

Merge pull request #4856 from xiang90/fail_key_cert

etcdmain: etcd should fail to start when https is enabled but tls con…
Xiang Li 9 years ago
parent
commit
7d2545c72e
1 changed files with 5 additions and 2 deletions
  1. 5 2
      etcdmain/etcd.go

+ 5 - 2
etcdmain/etcd.go

@@ -262,8 +262,11 @@ func startEtcd(cfg *config) (<-chan struct{}, error) {
 	}
 	}
 	sctxs := make(map[string]*serveCtx)
 	sctxs := make(map[string]*serveCtx)
 	for _, u := range cfg.lcurls {
 	for _, u := range cfg.lcurls {
-		if u.Scheme == "http" && !cfg.clientTLSInfo.Empty() {
-			plog.Warningf("The scheme of client url %s is http while client key/cert files are presented. Ignored client key/cert files.", u.String())
+		if u.Scheme == "http" && ctlscfg != nil {
+			plog.Warningf("The scheme of client url %s is HTTP while client key/cert files are presented. Ignored client key/cert files.", u.String())
+		}
+		if u.Scheme == "https" && ctlscfg == nil {
+			return nil, fmt.Errorf("TLS key/cert (--cert-file, --key-file) must be provided for client url %s with HTTPs scheme", u.String())
 		}
 		}
 
 
 		ctx := &serveCtx{host: u.Host}
 		ctx := &serveCtx{host: u.Host}