Skip to content

Commit 00a28f6

Browse files
committed
Improve IPv6 address handling in ocspserve
When setting an IPv6 address to listing on via the -address command-line argument for both serve and ocspserve, the latter errors with "listen tcp: address ::1:8889: too many colons in address" unless it is escaped. However, the former uses the net library to process the address and port, which results in the enforced escaping of IPv6 addresses regardless of if the address is already enclosed in square brackets (e.g. [::1]). This changes oscpserve to use the same net library call as serve to provide consistency between the two calls when handling IPv6 addresses.
1 parent 6dd12c2 commit 00a28f6

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

cli/ocspserve/ocspserve.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ package ocspserve
33

44
import (
55
"errors"
6-
"fmt"
6+
"net"
77
"net/http"
8+
"strconv"
89

910
"github.com/cloudflare/cfssl/cli"
1011
"github.com/cloudflare/cfssl/log"
@@ -53,7 +54,7 @@ func ocspServerMain(args []string, c cli.Config) error {
5354
log.Info("Registering OCSP responder handler")
5455
http.Handle(c.Path, ocsp.NewResponder(src, nil))
5556

56-
addr := fmt.Sprintf("%s:%d", c.Address, c.Port)
57+
addr := net.JoinHostPort(c.Address, strconv.Itoa(c.Port))
5758
log.Info("Now listening on ", addr)
5859
return http.ListenAndServe(addr, nil)
5960
}

0 commit comments

Comments
 (0)