Thursday 22 October 2020

 Error "-bash: !2: event not found" while converting the PKCS12 keystore (.p12/.pfx) to the Java Keystore (.jks)


Introduction:

Some times there is a need to convert the PKCS12 keystore to the Java Keystore or vice versa. This post will cover how to convert the PKCS12 keystore to the java keystore.


Commands and details:

* Please do no apply any of the following command on the PROD, always test the commands on TEST or DEV machine and if you think its fine then do on PROD with full responsibility of your own.*

1- make a test / working directory

2- copy the PKCS12 keystore in that directory, make a backup of the original PKCS12 keystore

3- run the following command

[testuser@testserver1020 workingdirectory]# keytool -importkeystore -deststorepass KeepTheStrongPassword4TargetKeystore -destkeypass KeepTheStrongPassword4TargetKeystore -destkeystore new_java_keystore_name.jks -destalias AliasOfTheCert -srckeystore server.pfx -srcstoretype PKCS12 -srcstorepass TheSourcePKCS12KeystorePassword

output: 

Above command might give the following error

-bash: !2: event not found


Resolution of the error:

give the following command with out "-srcstorepass TheSourcePKCS12KeystorePassword", and the command will ask you the password on the prompt, give the password and it will convert the PKCS12 file to JKS keystore


[testuser@testserver1020 workingdirectory]# keytool -importkeystore -deststorepass KeepTheStrongPassword4TargetKeystore -destkeypass KeepTheStrongPassword4TargetKeystore -destkeystore new_java_keystore_name.jks -destalias AliasOfTheCert -srckeystore server.pfx -srcstoretype PKCS12

Enter source keystore password:

Entry for alias SourceAlias successfully imported.

Import command completed:  1 entries successfully imported, 0 entries failed or cancelled



 Oracle Weblogic 12.2.1.3.0 60820: Select a domain which is a compatible with this environment. stopComponent.sh and start Component.sh give...