Legend [Text in this format explains the reason behind the steps] Text in this format shows the actual command
How to generate self signed certificates keytool -genkey -alias
-keypass <password> -keyalg RSA keytool -export -alias -file <.crt file>
How to Generate Code Signing CSR Run these commands keytool -genkey -keystore -alias -keyalg RSA keytool -genkey -keystore servicestore -alias servicealias -keyalg RSA The private and public keys are being generated and stored in password protected keystore. keytool -certreq
-keystore
-alias
-file
keytool -certreq -keystore servicestore -alias servicealias -file signing.csr CSR contains the public key generated above along with other info like OU etc etc which needs to be sent to CA. CA will sign our public with its private key, vouching that we are “authentic” signers of the code. CA will send us back this back as a cerificate.
The CSR is generated in the file signing.csr. This is to be sent to the CA (Say Verisign) for certificate. A file will be created in your current working folder with name or servicestore. Preserve this file and remember all passwords: store password and key password. Running the command above will ask for options like keystore name, password, alias and other thing like CN, O, OU etc… How to Install Code Signing Certificate Step 1: Import the certificate from CA (Say verisign) into your store keytool -import -alias -storepass <store.password>
-file
file>
keytool -import -alias servicealias -file cert.cer -keystore servicestore -storepass muser12
is certificate sent by Verisign.
-keystore
Our self signed private and public keys need to be replaced with the CA signed keys by importing the CA certificate to the keystore. Since a key store can contain many keys, alias is used to identify particular set of keys.
Step 3: Use the attached class file or Java file javac UserInfo.java jar –cvf *.class jar –cvf uUser.jar *.class
Step 3: Sign the Jar file jarsigner -keystore -storepass <store.password> -keypass -signedjar <Signed Jar File name> jarsigner -keystore servicestore -storepass muser12 -keypass muser12 -signedjar UserInfo.jar uUser.jar servicealias In this step, the jar file is signed by our private key and also our public key (which has been signed and certified by CA) is stored along with the code.
Step 4: Upload the file Upload <Signed Jar File name>.jar When the end user accesses signed code, he will be asked to trust our public key which has been vouched for by CA.
Restart of web servers is not required