Skip to content

crypto/x509: return informative error if wrong type passed to MarshalPKIXPublicKey #32640

Description

@mathieudevos

What version of Go are you using (go version)?

$ go version
go1.12.5

Does this issue reproduce with the latest release?

Not applicable

What did you do?

What did you expect to see?

Expected to see an error stating it requires a pointer, or for it to resolve instead

What did you see instead?

panic: x509: only RSA and ECDSA public keys supported

My suggestion, in https://golang.org/src/crypto/x509/x509.go?s=3023:3081#L68 , the function marshalPublicKey add 2 cases with simple recursion:

case rsa.PublicKey:
    return marshalPublicKey(&pub)
case ecdsa.PublicKey
    return marshalPublicKey(&pub)

Or same as above, but return error that states that it must be a pointer.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions