| 1 |
package dns |
| 2 |
|
| 3 |
import ( |
| 4 |
"crypto/x509" |
| 5 |
) |
| 6 |
|
| 7 |
// Sign creates a SMIMEA record from an SSL certificate. |
| 8 |
func (rr *SMIMEA) 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 SMIMEA record against a TLS certificate. If it is OK a nil error is returned. |
| 18 |
func (rr *SMIMEA) 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 |
} |