bugfix check returns of pem.Decode

This commit is contained in:
Stéphane Depierrepont aka Toorop
2015-10-20 12:29:39 +02:00
parent 4b92c72b9a
commit 229ddd54a8

View File

@@ -106,6 +106,9 @@ func Sign(email *[]byte, options SigOptions) error {
return ErrSignPrivateKeyRequired return ErrSignPrivateKeyRequired
} }
d, _ := pem.Decode(options.PrivateKey) d, _ := pem.Decode(options.PrivateKey)
if d == nil {
return ErrCandNotParsePrivateKey
}
key, err := x509.ParsePKCS1PrivateKey(d.Bytes) key, err := x509.ParsePKCS1PrivateKey(d.Bytes)
if err != nil { if err != nil {
return ErrCandNotParsePrivateKey return ErrCandNotParsePrivateKey