How to create an empty Java trust store?

I want to make an https client in java that initially does not have trusted CA certificates. Since I do not want the JVM to use the cacerts file by default, I have to create an empty trust store and point it to the JVM.
How to create an empty trust store?

+4
source share
1 answer

One possible solution that I found is to import some random certificate into the newly created trust store using keytool import, and then remove the imported certificate from it. This leaves you with a blank key / trust store. Unfortunately, the JVM is unhappy with the empty trust store and throws an exception. Therefore, in order to achieve the goal, at least one certificate must be present, which can be any invalid or expired.

+2
source

All Articles