Skip to content

Commit

Permalink
Merge pull request #41 from mkontani/configurable-host
Browse files Browse the repository at this point in the history
add tlshost option
  • Loading branch information
maditya authored Jun 24, 2020
2 parents 4842fed + f52c5f3 commit 659eb6a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
5 changes: 5 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -87,6 +88,7 @@ type Config struct {
TLSServerCertPath string
TLSServerKeyPath string
TLSCACertPath string
TLSHost string
TLSPort string
SignersPerPool int
Keys []KeyConfig
Expand Down Expand Up @@ -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
}
Expand Down
1 change: 1 addition & 0 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
2 changes: 1 addition & 1 deletion server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 659eb6a

Please sign in to comment.