| 1 | package dnsscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/ |
| 2 | |
| 3 | import ( |
| 4 | "crypto/x509scip-go gomod github.com/golang/go/src go1.25.0 `crypto/x509`/" |
| 5 | "netscip-go gomod github.com/golang/go/src go1.25.0 net/" |
| 6 | "strconvscip-go gomod github.com/golang/go/src go1.25.0 strconv/" |
| 7 | ) |
| 8 | |
| 9 | // Sign creates a TLSA record from an SSL certificate. |
| 10 | func (r *TLSAscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/TLSA#) Signscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/TLSA#Sign().(usage, selector, matchingType int, cert *x509scip-go gomod github.com/golang/go/src go1.25.0 `crypto/x509`/.Certificatescip-go gomod github.com/golang/go/src go1.25.0 `crypto/x509`/Certificate#) (err error) { |
| 11 | r.Hdrscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/TLSA#Hdr..Rrtypescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/RR_Header#Rrtype. = TypeTLSAscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/TypeTLSA. |
| 12 | r.Usagescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/TLSA#Usage. = uint8(usage) |
| 13 | r.Selectorscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/TLSA#Selector. = uint8(selector) |
| 14 | r.MatchingTypescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/TLSA#MatchingType. = uint8(matchingType) |
| 15 | |
| 16 | r.Certificatescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/TLSA#Certificate., err = CertificateToDANEscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/CertificateToDANE().(r.Selectorscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/TLSA#Selector., r.MatchingTypescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/TLSA#MatchingType., cert) |
| 17 | return err |
| 18 | } |
| 19 | |
| 20 | // Verify verifies a TLSA record against an SSL certificate. If it is OK |
| 21 | // a nil error is returned. |
| 22 | func (r *TLSAscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/TLSA#) Verifyscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/TLSA#Verify().(cert *x509scip-go gomod github.com/golang/go/src go1.25.0 `crypto/x509`/.Certificatescip-go gomod github.com/golang/go/src go1.25.0 `crypto/x509`/Certificate#) error { |
| 23 | c, err := CertificateToDANEscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/CertificateToDANE().(r.Selectorscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/TLSA#Selector., r.MatchingTypescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/TLSA#MatchingType., cert) |
| 24 | if err != nil { |
| 25 | return err // Not also ErrSig? |
| 26 | } |
| 27 | if r.Certificatescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/TLSA#Certificate. == c { |
| 28 | return nil |
| 29 | } |
| 30 | return ErrSigscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/ErrSig. // ErrSig, really? |
| 31 | } |
| 32 | |
| 33 | // TLSAName returns the ownername of a TLSA resource record as per the |
| 34 | // rules specified in RFC 6698, Section 3. |
| 35 | func TLSANamescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/TLSAName().(name, service, network string) (string, error) { |
| 36 | if !IsFqdnscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/IsFqdn().(name) { |
| 37 | return "", ErrFqdnscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/ErrFqdn. |
| 38 | } |
| 39 | p, err := netscip-go gomod github.com/golang/go/src go1.25.0 net/.LookupPortscip-go gomod github.com/golang/go/src go1.25.0 net/LookupPort().(network, service) |
| 40 | if err != nil { |
| 41 | return "", err |
| 42 | } |
| 43 | return "_" + strconvscip-go gomod github.com/golang/go/src go1.25.0 strconv/.Itoascip-go gomod github.com/golang/go/src go1.25.0 strconv/Itoa().(p) + "._" + network + "." + name, nil |
| 44 | } |