forked from TrueCloudLab/certificates
acme/authority: Polymorph the challenge type
Prior to validation, we must wrap the base challenge in the correct concrete challenge type so that we dispatch the correct validation method.
This commit is contained in:
parent
2d0a00c4e1
commit
a857c45847
2 changed files with 14 additions and 1 deletions
|
@ -372,7 +372,7 @@ func (a *Authority) validate(ch challenge, jwk *jose.JSONWebKey) (challenge, err
|
|||
dialer := &net.Dialer{
|
||||
Timeout: 30 * time.Second,
|
||||
}
|
||||
return ch.validate(jwk, validateOptions{
|
||||
return ch.clone().morph().validate(jwk, validateOptions{
|
||||
httpGet: client.Get,
|
||||
lookupTxt: net.LookupTXT,
|
||||
tlsDial: func(network, addr string, config *tls.Config) (*tls.Conn, error) {
|
||||
|
|
|
@ -291,6 +291,19 @@ func unmarshalChallenge(data []byte) (challenge, error) {
|
|||
}
|
||||
}
|
||||
|
||||
func (bc *baseChallenge) morph() challenge {
|
||||
switch bc.getType() {
|
||||
case "dns-01":
|
||||
return &dns01Challenge{bc}
|
||||
case "http-01":
|
||||
return &http01Challenge{bc}
|
||||
case "tls-alpn-01":
|
||||
return &tlsALPN01Challenge{bc}
|
||||
default:
|
||||
panic("unrecognized challenge type: " + bc.getType())
|
||||
}
|
||||
}
|
||||
|
||||
// Challenge retry information is internally relevant and needs to be stored in the DB, but should not be part
|
||||
// of the public challenge API apart from the Retry-After header.
|
||||
type Retry struct {
|
||||
|
|
Loading…
Reference in a new issue