Skip to content
This repository has been archived by the owner on Sep 7, 2022. It is now read-only.

Only listen for HTTP challenge when needed. #58

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions cert.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,13 +167,6 @@ func authz(ctx context.Context, client *acme.Client, domain string) error {
return errors.New("no supported challenge found")
}

// respond to http-01 challenge
ln, err := net.Listen("tcp", certAddr)
if err != nil {
return fmt.Errorf("listen %s: %v", certAddr, err)
}
defer ln.Close()

switch {
case certManual:
// manual challenge response
Expand All @@ -199,6 +192,13 @@ func authz(ctx context.Context, client *acme.Client, domain string) error {
var x string
fmt.Scanln(&x)
default:
// listen for http-01 challenge
ln, err := net.Listen("tcp", certAddr)
if err != nil {
return fmt.Errorf("listen %s: %v", certAddr, err)
}
defer ln.Close()

// auto, via local server
val, err := client.HTTP01ChallengeResponse(chal.Token)
if err != nil {
Expand Down