Skip to content

crypto/x509: better documentation for ParsePKIXPublicKey #14355

Description

@dndx

In the latest Golang release (1.5.3), the documentation for x509.ParsePKIXPublicKey() says the function takes in a []byte of DER encoded public key and returns pub interface{}. It is not obvious exactly what pub is or how to use it unless digging inside the source code and trace to the function parsePublicKey().

Suggested changes:

  • Mention explicitly what kind of public key input we support (RSA, DSA, ECDSA)
  • Mention the type of pub in those three cases respectively
  • Add a short example on how to use switch statement along with type assertions to obtain the correct type of public key.

I will be happy to make those improvements to the document and submit for code review if no objections from the project maintainers.

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

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions