Merge branch 'add-shttp-bind-fallback'

This commit is contained in:
xenolf 2015-11-09 19:03:07 +01:00
commit 959cf005c7
2 changed files with 7 additions and 3 deletions

View file

@ -126,7 +126,11 @@ func (s *simpleHTTPChallenge) startHTTPSServer(domain string, token string) (net
tlsListener, err := tls.Listen("tcp", domain+port, tlsConf)
if err != nil {
return nil, err
// if the domain:port bind failed, fall back to :port bind and try that instead.
tlsListener, err = tls.Listen("tcp", port, tlsConf)
if err != nil {
return nil, err
}
}
jsonBytes, err := json.Marshal(challenge{Type: "simpleHttp", Token: token, TLS: true})

View file

@ -24,9 +24,9 @@ func TestSimpleHTTPNonRootBind(t *testing.T) {
if err := solver.Solve(clientChallenge, "127.0.0.1"); err == nil {
t.Error("BIND: Expected Solve to return an error but the error was nil.")
} else {
expectedError := "Could not start HTTPS server for challenge -> listen tcp 127.0.0.1:443: bind: permission denied"
expectedError := "Could not start HTTPS server for challenge -> listen tcp :443: bind: permission denied"
if err.Error() != expectedError {
t.Errorf("Expected error %s but instead got %s", expectedError, err.Error())
t.Errorf("Expected error \"%s\" but instead got \"%s\"", expectedError, err.Error())
}
}
}