Skip to content

Commit

Permalink
Improve IPv6 address handling in ocspserve
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jonathanio committed May 8, 2021
1 parent 6dd12c2 commit 00a28f6
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions cli/ocspserve/ocspserve.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ package ocspserve

import (
"errors"
"fmt"
"net"
"net/http"
"strconv"

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

addr := fmt.Sprintf("%s:%d", c.Address, c.Port)
addr := net.JoinHostPort(c.Address, strconv.Itoa(c.Port))
log.Info("Now listening on ", addr)
return http.ListenAndServe(addr, nil)
}
Expand Down

0 comments on commit 00a28f6

Please sign in to comment.