Search code examples
javatomcatkeystore

Tomcat unable to locate desired keystore by Daemon Service Manager


Currently I'm using java code to load KeyStore through .cmd by Runtime.getRuntime().exec() to execute java -jar main.jar

The Code

this.ks = KeyStore.getInstance("Windows-MY");
this.ks.load(null, null);

The program is able to load x509 Certificate by using the startup.bat provided by Tomcat by default. (running in Administrator Account)

This is not working using Daemon Service Manager to start Tomcat, the KeyStore always returns empty.

I also tried using different accounts, but sadly same result: Empty KeyStore

Account Settings Sample

I already loaded the private key and all needed certificates to Local Computer / Current User.

How can I make this work?


Solution

  • The problem was the services account didn't have the key loaded.

    Using Microsoft MMC won't work, as this will not run as services account and the key only loaded to users' store.

    Use tools like PsExec.exe to load the key by commands.