Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Accessing Windows Certificate Store certs via Java?

I'm looking to write something that can enumerate and use (to sign) certificates in CurrentUser/My and LocalMachine/My, but I haven't been able to find anything for the Windows cert store, only Java's own secret store. This link looks promising, but I can only use what ships with Java.

I found this question asked on SO before, but it's from five years ago, which is a long time in computer years. Thanks!

like image 644
Benjin Avatar asked Dec 08 '15 21:12

Benjin


People also ask

Where does Java store trusted certificates?

Java stores the trusted certificates in a special file named cacerts that lives inside our Java installation folder. The default password for this KeyStore is “changeit”, but it could be different if it was previously changed in our system.

Does Java have its own certificate store?

Java's list of trusted certificates is stored in its default truststore. This file is usually called cacerts .

What is cacerts file in Java?

The cacerts file represents a system-wide keystore with CA certificates. System administrators can configure and manage that file using keytool, specifying jks as the keystore type. The cacerts keystore file ships with several root CA certificates. The initial password of the cacerts keystore file is changeit .


2 Answers

Start Java with -Djavax.net.ssl.trustStoreType=WINDOWS-ROOT.

See https://www.oracle.com/technical-resources/articles/javase/security.html for more information.

like image 164
michael.kebe Avatar answered Sep 20 '22 11:09

michael.kebe


The cross-platform nature of the Java has its own downsides -- you cannot access some (or many) OS-specific things without external libraries. Windows certificate store is accessible only via CryptoAPI native functions which are not support by Java default installation.

You may take a look at this thread: Calling Win32 API method from Java

If you can use JNA, then you can use various Certificate and Certificate Store Functions in crypt32.dll to enumerate certificates and perform signing operations.

like image 35
Crypt32 Avatar answered Sep 21 '22 11:09

Crypt32