Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how can i get a es384 JWT TOKEN with only a pem file ? #204

Open
bighamx opened this issue Nov 19, 2022 · 1 comment
Open

how can i get a es384 JWT TOKEN with only a pem file ? #204

bighamx opened this issue Nov 19, 2022 · 1 comment

Comments

@bighamx
Copy link

bighamx commented Nov 19, 2022

var payload = new Dictionary<string, object>()
{
//xxx
};

var privateKey = ???;
// only got a pem file like
//-----BEGIN PRIVATE KEY-----
//xxxxxxxxxxxxxxx
//-----END PRIVATE KEY-----

//how can i get a key for below jwt token generate

string token = Jose.JWT.Encode(payload, privateKey, JwsAlgorithm.ES384, new Dictionary<string, object>()
{
{ "alg", "ES384" },
{ "type", "JWT" },
});
i search for the web serveral hours and i got sth like this c# JWT load ES256 PEM file into CngKey (jose-jwt) but it cant solve my problem,i want to convert the pem file to p12 file,but i dont have a cert file,i only have a pem file. i realy need the solution, thanks.

@dvsekhvalnov
Copy link
Owner

dvsekhvalnov commented Nov 19, 2022

Hi @bighamx ,

https://www.scottbrady91.com/c-sharp/pem-loading-in-dotnet-core-and-dotnet ?

If you can't use any of those due to different .net version, you have to convert it to .p12, you really don't need cert to do that (or you can create any cert out of your key, cert is just bag of attributes, choose any you like, it doesn't matter for your usecase)

openssl pkcs12 -export -nocerts -inkey your.private.key.pem -out your.private.key.p12

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants