add DISABLE_TLS env var to pgo-apiserver
@@ -86,6 +86,15 @@ func main() {
}
tlsNoVerify, _ := strconv.ParseBool(tmp)
+ tmp = os.Getenv("DISABLE_TLS")
+ if tmp == "true" {
+ log.Debug("DISABLE_TLS set to true")
+ } else {
+ tmp = "false"
+ log.Debug("DISABLE_TLS set to false")
+ }
+ disableTLS, _ := strconv.ParseBool(tmp)
+
log.Infoln("postgres-operator apiserver starts")
apiserver.Initialize()
@@ -185,6 +194,7 @@ func main() {
}
caCertPool := x509.NewCertPool()
caCertPool.AppendCertsFromPEM(caCert)
+
cfg := &tls.Config{
ClientAuth: tls.RequireAndVerifyClientCert,
//specify pgo-apiserver in the CN....then, add ServerName: "pgo-apiserver",
@@ -196,12 +206,6 @@ func main() {
log.Info("listening on port " + PORT)
- srv := &http.Server{
- Addr: ":" + PORT,
- Handler: r,
- TLSConfig: cfg,
- }
-
_, err = ioutil.ReadFile(serverKeyPath)
if err != nil {
log.Fatal(err)
@@ -209,5 +213,20 @@ func main() {
os.Exit(2)
}
+ var srv *http.Server
+ if !disableTLS {
+ srv = &http.Server{
+ Addr: ":" + PORT,
+ Handler: r,
+ TLSConfig: cfg,
+ }
log.Fatal(srv.ListenAndServeTLS(serverCertPath, serverKeyPath))
+ } else {
+ srv = &http.Server{
+ Addr: ":" + PORT,
+ Handler: r,
+ }
+ log.Fatal(srv.ListenAndServe())
+ }
+
}
