forked from TrueCloudLab/lego
348b6f3721
* Resolve CNAME when creating dns-01 challenge It may be desirable to host the dns-01 challenge in a zone other than the one where the challenge is presented. For example, when validating a.example.com, the challenge may need to live on example.org. This change resolves CNAMEs encountered when determining the FQDN of the challenge, and replaces them with the alias. This PR is based on the original work in #584. Co-authored-by: Gurvinder Singh <gurvinder.singh@uninett.no> * review: feature-flip. * review: restore acmedns test.
16 lines
285 B
Go
16 lines
285 B
Go
package dns01
|
|
|
|
import "github.com/miekg/dns"
|
|
|
|
// Update FQDN with CNAME if any
|
|
func updateDomainWithCName(r *dns.Msg, fqdn string) string {
|
|
for _, rr := range r.Answer {
|
|
if cn, ok := rr.(*dns.CNAME); ok {
|
|
if cn.Hdr.Name == fqdn {
|
|
return cn.Target
|
|
}
|
|
}
|
|
}
|
|
|
|
return fqdn
|
|
}
|