Create a private and public key file using keytool

I want to know if there is a way to create a .key file for (public and private key) using keytool, I understand that we can create a keystore using the following command

keytool -genkeypair -keysize 2048 -keyalg RSA -alias appalias -keystore D:\..\..

which has keypair, I also know about the way to extract keys from the java key store, but does it have a direct way to use KEYTOOL

+4
source share
3 answers

According to the findings, there is no direct way to retrieve the private key from the keystore, this link How can I export my private key from the Java Keytool keystore? helped me extract the keys, this requires OpenSSL, but I think this is the only way to go.

+1
source

As far as I remember, puttygen can generate public and private key files. Try it and let me know if this works. Relations

http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html

0
source

keytool, .

/ keytool -export , keytool -import . :

keytool -export -alias clientprivate -keystore client.private -file temp.key -storepass clientpw

And here is the command to insert the client’s private key into their own keystore:

keytool -import -noprompt -alias clientpublic -keystore client.public -file temp.key -storepass public

We will also extract and save the server’s public key. Here is the command to extract the key:

keytool -export -alias serverprivate -keystore server.private -file temp.key -storepass serverpw

And here's the command to put it in your own keystore:

keytool -import -noprompt -alias serverpublic -keystore server.public -file temp.key -storepass public
0
source

Source: https://habr.com/ru/post/1609641/


All Articles