From f52c5f33a92b008396257f031af28212c2d28b5a Mon Sep 17 00:00:00 2001 From: mkontani Date: Wed, 24 Jun 2020 21:54:58 +0900 Subject: [PATCH] add tlshost option --- config/config.go | 5 +++++ config/config_test.go | 1 + server/server.go | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/config/config.go b/config/config.go index 18fcd150..1130f763 100644 --- a/config/config.go +++ b/config/config.go @@ -18,6 +18,7 @@ const ( defaultTLSServerCertPath = "/opt/crypki/server.crt" defaultTLSCACertPath = "/opt/crypki/ca.crt" defaultTLSServerKeyPath = "/opt/crypki/server.key" + defaultTLSHost = "" defaultTLSPort = "4443" defaultPoolSize = 2 defaultKeyType = crypki.RSA @@ -87,6 +88,7 @@ type Config struct { TLSServerCertPath string TLSServerKeyPath string TLSCACertPath string + TLSHost string TLSPort string SignersPerPool int Keys []KeyConfig @@ -179,6 +181,9 @@ func (c *Config) loadDefaults() { if c.SignersPerPool == 0 { c.SignersPerPool = defaultPoolSize } + if strings.TrimSpace(c.TLSHost) == "" { + c.TLSHost = defaultTLSHost + } if strings.TrimSpace(c.TLSPort) == "" { c.TLSPort = defaultTLSPort } diff --git a/config/config_test.go b/config/config_test.go index 8ac7f119..be618aec 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -16,6 +16,7 @@ func TestParse(t *testing.T) { TLSClientAuthMode: 4, TLSServerCertPath: "/opt/crypki/server.crt", TLSServerKeyPath: "/opt/crypki/server.key", + TLSHost: "", TLSPort: "4443", SignersPerPool: 2, Keys: []KeyConfig{ diff --git a/server/server.go b/server/server.go index 32242b79..bfa5189c 100644 --- a/server/server.go +++ b/server/server.go @@ -182,7 +182,7 @@ func Main(keyP crypki.KeyIDProcessor) { proto.RegisterSigningServer(grpcServer, ss) - server := initHTTPServer(ctx, tlsConfig, grpcServer, gwmux, net.JoinHostPort("", cfg.TLSPort)) + server := initHTTPServer(ctx, tlsConfig, grpcServer, gwmux, net.JoinHostPort(cfg.TLSHost, cfg.TLSPort)) listener, err := net.Listen("tcp", server.Addr) if err != nil {