Skip to content

Using private/public key example #131

@cope

Description

@cope

Hi, can you please provide an example of how to sign/verify using an existing private/public key pair?

I got it working in node with node-jsonwebtoken, like this:

var key = fs.readFileSync('private.key');
var pem = fs.readFileSync('public.pem');

var header = {...};
var payload = {...};

header.algorithm = "RS256";
var message = jsonwebtoken.sign(payload, key, header);
var decoded = jsonwebtoken.verify(message, pem, {algorithm: "RS256"});

And it works just fine.

I would like to do the same in Java.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementhelp-wantedIf you're looking to help the project, start with these!

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions