Search code examples
javakeystorewebsphere-8ibm-rad

How to view and edit cacerts file?


Using RAD 8.5 with WAS 8.5 runtime, I am getting an exception on my console:

The keystore located at "C:\IBM\Websphere85\jdk\jre\lib\security\cacerts" failed to load due to the following error: DerInputStream.getLength(): lengthTag=109, too big..

After searching for the error I got this link which suggests to edit the file and remove blank lines/extra characters.

How do I edit the file? I am on windows environment and the file seems to be base64 encoded.


Solution

  • Here's a way to actually solve this problem without the need to view or edit the file.

    The default keyStore type is JKS and the WSKeyStore class assumes it to be a PKCS12 file which throws the above error. So we need to convert the cacerts file to .p12 format.

    Using the keytool utility from command line I executed:

    C:\IBM\WebSphere85\AppServer\java\bin>keytool -importkeystore ^
     -srckeystore C:\IBM\WebSphere85\AppServer\java\jre\lib\security\cacerts ^
     -destkeystore C:\IBM\WebSphere85\AppServer\java\jre\lib\security\cacerts.p12 ^
     -srcstoretype JKS -deststoretype PKCS12 -srcstorepass changeit -deststorepass changeit -noprompt
    

    which gave me a cacerts.p12 file which could be easily read by the above class.

    References: