Add single Certificate to local JDK on linux servers
keytool -import -trustcacerts -keystore /filepath/java/jre/lib/security/cacerts -storepass changeit -noprompt -alias aliasName -file /certificateFilePath/certifcate.cer
Add a single cert on windows
keytool -importcert -trustcacerts -storepass changeit -noprompt -alias aliasName -file C:\Users\u6071754\Desktop\ofv_cert.cer
Add keystore
keytool -importkeystore -trustcacerts -keystore /filepath/java/jre/lib/security/cacerts -storepass changeit -noprompt -alias aliasName -srckeystore /keyStorePath/KeyStore.jks
Delete Certificate
keytool -delete -v -keystore /filepath/java/jre/lib/security/cacerts -alias aliasName
List All Certificates
keytool -list -v -keystore /filepath/java/jre/lib/security/cacerts > cert.txt
Cacert pwd is changeit
Command for importing Certificates to Keystore UNIX/Windows:-
Installing Certificate:-
<java installation directory>/bin/keytool -import -noprompt -trustcacerts -alias certificate –file certificate.cer -keystore DemoIdentity.jks -storepass DemoIdentityKeyStorePassPhrase
Viewing Certificates within Keystore:-
<java installation directory>/bin/keytool -list –v -keystore cacerts -storepass changeit
Deleting Certificate
keytool -delete -alias "mykey" -keystore ..\lib\security\cacerts
Locate the keytool from the java installation bin folder.
-alias :- Name with which the certificate is saved to the keystore
-storepass :- password for the keystore to which the new certificate is added.
The default java keystore is the cacerts file located under
<Java installation folder>/jre/lib/security/cacerts
Default password for the cacerts file is ”changeit”.
For Weblogic the keystore files used is DemoIdentity Keystore.
Password for the keystore :- DemoIdentityKeyStorePassPhrase
Add the certificates to the above files, for applications that can directly use the default certificates (Webservices etc) ie, the internal implementation uses the default providers to fetch the certificates directly from the JVM.
For other applications, like LDAP, Webservices that require certificates to be added along with the Request Body etc, Code level implementation has to be done.
Using Keystores in Java Application:-
Implementation using SSLSocket Factory:-
Create a keystore with the files provided (Using 3rdParty Tools like KeyStore Explorer etc).
Files provided may include the server, Intermediate and Root Certificate. Add all the files to a single keystore.
Provide a password while creating the Keystore and the file will have the .jks extension.
Provide the generated keystore to the SSLSocketFactroy.
Refer the below file for Implemetation of SSLSocketFactory to use the Keystore for an LDAP service. The SocketFactory is then set to the LDAP configuration during Authentication.