How to create keystore.jks and create private.der and public.der cert file -
Asked Answered
L

1

0

I am looking to implement token based authentication (Nimbus JOSE+JWT) in my Angular Spring MVC Application. I also wanted to implement the RSA based keystore tool and to have a 'Private' and 'public' key based authentication to identify the client. How can I do that ?

I simply need to do the following steps:

1) Create a .keystore
2) Generate private.der cert file
3) Generate public.der cert file. 

I know how to load the private and public key from the link : Load RSA public key from file (answer from JavaHelper), But can I proceed for this ?

Lael answered 13/8, 2016 at 17:26 Comment(0)
E
0

If need to download the openssl from the link: https://code.google.com/archive/p/openssl-for-windows/downloads. Download .zip file and extract into the any location. Go to that location till in my case its C:\openssl-0.9.8k_X64\bin.

As per link : https://rietta.com/blog/2012/01/27/openssl-generating-rsa-key-from-command/, you need to execute the following command:

You can generate a public and private RSA key pair like this:

openssl genrsa -des3 -out private.pem 2048

That generates a 2048-bit RSA key pair, encrypts them with a password you provide, and writes them to a file. You need to next extract the public key file. You will use this, for instance, on your web server to encrypt content so that it can only be read with the private key.

As per link: https://www.openssl.org/docs/manmaster/apps/pkcs8.html and https://superuser.com/questions/606215/openssl-pkcs8-default-format-gives-rsa-private-key

Read a DER unencrypted PKCS#8 format private key:

openssl pkcs8 -topk8 -inform pem -in file.key -outform pem -nocrypt -out file.pem

and create the public key like below

openssl rsa -in key.pem -pubout -out pubkey.pem

Done !!

Eldenelder answered 3/9, 2016 at 20:11 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.