From 327371d638bca62adf05943ff8f6b7c38ffc39bb Mon Sep 17 00:00:00 2001 From: Tom Anderson Date: Sat, 6 Nov 2021 23:11:12 +1030 Subject: [PATCH] Ensure passing unit tests --- rsa_utils.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/rsa_utils.go b/rsa_utils.go index 13cc38c3..677c86c2 100644 --- a/rsa_utils.go +++ b/rsa_utils.go @@ -5,6 +5,7 @@ import ( "crypto/x509" "encoding/pem" "errors" + "fmt" ) var ( @@ -91,8 +92,8 @@ func ParseRSAPublicKeyFromPEM(key []byte) (*rsa.PublicKey, error) { if cert, err := x509.ParseCertificate(block.Bytes); err == nil { parsedKey = cert.PublicKey } else { - if parsedKey, err = x509.ParsePKCS1PublicKey(block.Bytes); err == nil { - return nil, err + if parsedKey, err = x509.ParsePKCS1PublicKey(block.Bytes); err != nil { + return nil, fmt.Errorf("%v - %w", ErrNotRSAPublicKey.Error(), err) } } }