Skip to content

Commit

Permalink
Add certificate signature verifier
Browse files Browse the repository at this point in the history
  • Loading branch information
jessepeterson committed Jun 17, 2021
1 parent ac30b74 commit fb68ac0
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion certverify/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"errors"
)

// Verifier is a simple certificate verifier
// PoolVerifier is a simple certificate verifier
type PoolVerifier struct {
verifyOpts x509.VerifyOptions
}
Expand Down
28 changes: 28 additions & 0 deletions certverify/signature.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package certverify

import (
"crypto/x509"
"errors"
)

// SignatureVerifier is a simple certificate verifier
type SignatureVerifier struct {
ca *x509.Certificate
}

// NewSignatureVerifier creates a new Verifier
func NewSignatureVerifier(rootPEM []byte) (*SignatureVerifier, error) {
ca, err := x509.ParseCertificate(rootPEM)
if err != nil {
return nil, err
}
return &SignatureVerifier{ca: ca}, nil
}

// Verify checks only the signature of the certificate against the CA
func (v *SignatureVerifier) Verify(cert *x509.Certificate) error {
if cert == nil {
return errors.New("missing MDM certificate")
}
return cert.CheckSignatureFrom(v.ca)
}

0 comments on commit fb68ac0

Please sign in to comment.