I want to retrieve the csr file from jks or cer file (have lost the .csr file). Please let know if it's possible from keytool command.
You cannot generate a certificate request from a certificate file. You can only do it for a KeyPair that is in your keystore (jks). You can run this keytool
command to generate a csr (pkcs#10)
keytool -certreq -keystore [KEYSTORE_PATH] -storepass [KEYSTORE_PASSWORD] -alias [KEYPAIR_ALIAS] -file [CSR_FILE]
You can see the content of the csr you generated by using the below command.
keytool -printcertreq -file [CSR_FILE]