I first generated jks using
keytool -genkey -alias keyAlias-keyalg RSA -keypass changeit -storepass changeit keystore keystore.jks
Then i generated the csr using
keytool -certreq -alias $addr -sigalg SHA256withRSA -keystore $addr.jks -file $addr.csr
Below is how i self sign and generate the .cer from jks
Export the generated certificate to the server.cer file (or client.cer if you prefer), using the following command format:
keytool -export -alias keyAlias-storepass changeit -file server.cer -keystore keystore.jks
If you ask me why i need to generate the cer from csr instead of jks then the reason is -sigalg SHA256withRSA does not work with -genkey (jks) so i have to use .csr and then use that csr to generate the self signed .cer
Question:
How can i self sign and generate the .cer from the .csr file instead of the .jks using keytool?