Debian Codegraph @

tlsa.go

raw
1 package dns
2
3 import (
4 "crypto/x509"
5 )
6
7 // Sign creates a TLSA record from a TLS certificate.
8 func (rr *TLSA) Sign(usage, selector, matchingtype int, cert *x509.Certificate) (err error) {
9 rr.Usage = uint8(usage)
10 rr.Selector = uint8(selector)
11 rr.MatchingType = uint8(matchingtype)
12
13 rr.Certificate, err = certificateToDANE(rr.Selector, rr.MatchingType, cert)
14 return err
15 }
16
17 // Verify verifies a TLSA record against a TLS certificate. If it is OK a nil error is returned.
18 func (rr *TLSA) Verify(cert *x509.Certificate) error {
19 c, err := certificateToDANE(rr.Selector, rr.MatchingType, cert)
20 if err != nil {
21 return err
22 }
23 if rr.Certificate == c {
24 return nil
25 }
26 return ErrSig
27 }