feat: specific error if certificate is invalid

This commit is contained in:
theexiile1305 2024-09-26 17:28:24 +02:00
parent 4b60557518
commit 79f22fb722
No known key found for this signature in database
GPG key ID: A1BDDE98F2BF6E40

View file

@ -16,6 +16,9 @@ var (
// ErrInvalidKeyPair should be used if key pair is invalid // ErrInvalidKeyPair should be used if key pair is invalid
ErrInvalidKeyPair = errors.New("invalid key pair") ErrInvalidKeyPair = errors.New("invalid key pair")
// ErrInvalidCertificate should be used if a certificate is invalid
ErrInvalidCertificate = errors.New("invalid certificate")
// ErrCouldNotInitialize should be used if the signed data could not initialize // ErrCouldNotInitialize should be used if the signed data could not initialize
ErrCouldNotInitialize = errors.New("could not initialize signed data") ErrCouldNotInitialize = errors.New("could not initialize signed data")
@ -46,7 +49,7 @@ func newSMime(keyPair *tls.Certificate) (*SMime, error) {
for _, cert := range keyPair.Certificate[1:] { for _, cert := range keyPair.Certificate[1:] {
c, err := x509.ParseCertificate(cert) c, err := x509.ParseCertificate(cert)
if err != nil { if err != nil {
return nil, err return nil, ErrInvalidCertificate
} }
parentCertificates = append(parentCertificates, c) parentCertificates = append(parentCertificates, c)
} }