Resetting a Lost pskey Password

Recently, I had to install a new certificate on a web server, but was unable to open the keystore where the private key was generated. At some point, the password for the pskey file has been changed (or not documented when set) so I was unable to open the file. I didn’t want to loose the private key, so I had to find a way to get into the keystore.

JKS files

The pskey file is just a JKS (Java KeyStore) file and has a well documented format. There isn’t a built-in way to reset the password using pskeymanager or keytool (without knowing the existing one), but we can rewrite the JKS file and add in a new password. This gist has two classes that you can compile to rewrite your pskey file.

This does not change the passwords on your private keys inside the keystore, just the password that opens the keystore itself.

Compile and Run

You will need to download the two classes and compile them. Save the files as:

  • ChangePassword.java
  • JKS.java

Make sure you have a JDK installed on your machine; you need to have the javac compiler. Compile the two classes with this command:

javac ChangePassword.java

After it compiles, you will have to new .class files. Copy your pskey from the web server to the folder where you compiled the two classes. Finally, let’s rewrite our pskey file with a new password:

java ChangePassword pskey pskey-new

You will be prompted to enter a new password. Now you have a new keystore file. The contents are the same, but the keystore password is reset. You can copy the pskey-new file to your web server and rename it back to pskey. If the password is new, you will need to update the Keystore tab in the WebLogic console, and update your integrationGateway.properties file.


This should be a last resort, but if you find yourself unable to open pskey you can always give this a try. Make to sure back up your pskey file before you try anything. You don’t want to try this and end up losing the keystore completely!

2 thoughts on “Resetting a Lost pskey Password

  1. Can ‘t compile the code, keep getting errors below:

    c:\Program Files\Java\jdk1.8.0_131\bin>javac “c:\Users\clead\Desktop\test keystore\ChangePassword.java”
    c:\Users\clead\Desktop\test keystore\ChangePassword.java:7: error: cannot find symbol
    private final static JKS j = new JKS();
    ^
    symbol: class JKS
    location: class ChangePassword
    c:\Users\clead\Desktop\test keystore\ChangePassword.java:7: error: cannot find symbol
    private final static JKS j = new JKS();
    ^
    symbol: class JKS
    location: class ChangePassword
    2 errors

Leave a Reply

Your email address will not be published. Required fields are marked *

To create code blocks or other preformatted text, indent by four spaces:

    This will be displayed in a monospaced font. The first four 
    spaces will be stripped off, but all other whitespace
    will be preserved.
    
    Markdown is turned off in code blocks:
     [This is not a link](http://example.com)

To create not a block, but an inline code span, use backticks:

Here is some inline `code`.

For more help see http://daringfireball.net/projects/markdown/syntax