Skip to content

x509: malformed tbs certificate #293

@Moranilt

Description

@Moranilt

I want to sign my toklens using RSA256. For that I've generated public and private PEM keys, where private key create with x509.MarshalPKCS1PrivateKey and public key with x509.MarshalPKCS1PublicKey.

And when I'm using jwt.ParseRSAPublicKeyFromPEM, I've go an error x509: malformed tbs certificate. I thought that I did something wrong while generating keys, but I didn't. The answer was inside the jwt.ParseRSAPublicKeyFromPEM, it's using x509.ParsePKIXPublicKey istead of x509.ParsePKCS1PublicKey. So I should change the algorythm to generate public key with x509.MarshalPKIXPublicKey.

But it's not obvious! Can someone explain to me why is it done in such way(using x509.ParsePKIXPublicKey), but not using x509.ParsePKCS1PublicKey if name of the function(ParseRSAPublicKeyFromPEM) is telling me to use RSA PUBLIC KEY which will be the pair to my private key?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions