- using
keytool - using
openssl genrsa - using
ssh-agent
Those tools achieve same propose as following same encypt spec but producing different file formats. Also keytool and ssh-agent providing passphase to protect private key.
this is tool specify for JAVA, the tool will create keystore which is JAVA concept that JAVA can easily process the key
reference:
difference-between-keytool-and-openssl
Difference between OpenSSL and keytool
Java JWT Token Tutorial using JJWT Library
most common tool to create encryption key, default create key in .pem format with base64Encode the binay key resulting 3 part: header with -----BEGIN RSA PRIVATE KEY-----, body with base64Encode string, footer with -----END RSA PRIVATE KEY-----
tool normally for creating private/ public key for ssh access
if you using keytool generating .jks file will be the most JAVA way, follow
this
, but less compatible with other tools, need step to convert file to .pem ..etc format.
if using openssl genrsa or ssh-agent to create .pem refer this, that need more JAVA code to handle. Also we need encode private key to pkcs8 format .pem file to support JAVA.
we can also use openssl genrsa to convert .pem file to .der file refer this, this way need less JAVA code to handle so will be less overhead.This is same as .pem that we need encode private key to pkcs8 format but output .der file to support JAVA.
mvn installsh jwt_key_pair.shgenerated public/ private key- replace
privateKeyPathandpublicKeyPathin App.java - run App.java