Skip to content

Commit 5e7d0e9

Browse files
shatilbobveznat
authored andcommitted
Resolves #2 "Support binding to localhost"
Introduces user-configured listen address and defaults to a more secure listen address of `127.0.0.1:8080`.
1 parent 7569ae4 commit 5e7d0e9

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

sign_certd.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -620,6 +620,11 @@ func signdFlags() []cli.Flag {
620620
Value: configPath,
621621
Usage: "Path to config.json",
622622
},
623+
cli.StringFlag{
624+
Name: "listen-address",
625+
Value: "127.0.0.1:8080",
626+
Usage: "HTTP service address",
627+
},
623628
}
624629
}
625630

@@ -636,7 +641,7 @@ func signCertd(c *cli.Context) error {
636641
return cli.NewExitError(fmt.Sprintf("Error validation config for env '%s': %s", envName, err), 1)
637642
}
638643
}
639-
err = runSignCertd(config)
644+
err = runSignCertd(config, c.String("listen-address"))
640645
return err
641646
}
642647

@@ -647,7 +652,7 @@ func makeCertRequestHandler(config map[string]ssh_ca_util.SignerdConfig) certReq
647652
return requestHandler
648653
}
649654

650-
func runSignCertd(config map[string]ssh_ca_util.SignerdConfig) error {
655+
func runSignCertd(config map[string]ssh_ca_util.SignerdConfig, addr string) error {
651656
log.Println("Server running version", ssh_ca_util.BuildVersion)
652657
log.Println("Using SSH agent at", os.Getenv("SSH_AUTH_SOCK"))
653658

@@ -671,6 +676,6 @@ func runSignCertd(config map[string]ssh_ca_util.SignerdConfig) error {
671676
request := r.Path("/cert/requests/{requestID}").Subrouter()
672677
request.Methods("GET").HandlerFunc(requestHandler.getRequestStatus)
673678
request.Methods("POST", "DELETE").HandlerFunc(requestHandler.signOrRejectRequest)
674-
http.ListenAndServe(":8080", r)
679+
http.ListenAndServe(addr, r)
675680
return nil
676681
}

0 commit comments

Comments
 (0)