-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ac30b74
commit fb68ac0
Showing
2 changed files
with
29 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} |