Skip to content

Commit

Permalink
crypto/x509: improve error when parsing bad ECDSA cert
Browse files Browse the repository at this point in the history
when parsing an ECDSA certificate, improve the error message upon
failing to parse the curve as a named curve, rather than returning
the original ASN1 error.

Fixes golang#21502 (sort of, to the extent that it needs fixing)
  • Loading branch information
jakob223 committed Aug 18, 2017
1 parent e998316 commit c072828
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/crypto/x509/x509.go
Expand Up @@ -1020,7 +1020,7 @@ func parsePublicKey(algo PublicKeyAlgorithm, keyData *publicKeyInfo) (interface{
namedCurveOID := new(asn1.ObjectIdentifier)
rest, err := asn1.Unmarshal(paramsData, namedCurveOID)
if err != nil {
return nil, err
return nil, errors.New("x509: failed to parse ECDSA parameters as namedCurve")
}
if len(rest) != 0 {
return nil, errors.New("x509: trailing data after ECDSA parameters")
Expand Down

0 comments on commit c072828

Please sign in to comment.