Generate a Public and Private Key Pair
- Generate a keystore with private key
keytool -genkey -v -alias YOUR_ALIAS>'' -keyalg EC -sigalg SHA256withECDSA -deststoretype pkcs12 -keystore <FILE_NAME>
.jks -dname "CN=xxx,OU=xxx,O=xxx,L=xxx,ST=xxx,C=CN" -validity 365 -storepass <YOUR_PASSWORD>
-keypass <YOUR_PASSWORD>
- Export the certificate corresponding to the private key
keytool -export -alias <YOUR_ALIAS>
-keystore <FILE_NAME>
.jks -storepass <YOUR_PASSWORD>
-rfc -file <FILE_NAME>
.cer
- Extract the public key from the certificate
openssl x509 -in <FILE_NAME>
.cer -pubkey -noout > <FILE_NAME>
.pem