diff --git a/pkcs12/pkcs12.go b/pkcs12/pkcs12.go index 55f7691..3e2ce69 100644 --- a/pkcs12/pkcs12.go +++ b/pkcs12/pkcs12.go @@ -252,6 +252,7 @@ func Decode(pfxData []byte, password string) (privateKey interface{}, certificat case bag.Id.Equal(oidPKCS8ShroundedKeyBag): if privateKey != nil { err = errors.New("pkcs12: expected exactly one key bag") + return nil, nil, err } if privateKey, err = decodePkcs8ShroudedKeyBag(bag.Value.Bytes, encodedPassword); err != nil {