Dynamically retrieve SSL client certificate

S

stevenmartin2000

I have a problem where the SSL client certificate that I need in my
keystore changes fairly often.

Is there a way I can store the client cert in a DB or the filesystem,
and then dynamically access it when making SSL connections in Java?
That way I could just replace the certificate and no code changes or
keystore modifications would be needed.

I tried the following code, but it only seems to be able to add
certificates that I will trust and not who I am:

FileInputStream fis = new
FileInputStream(keyStore);
KeyStore ks = KeyStore.getInstance("jks");
ks.load(fis, keyStorePassword.toCharArray());
fis.close();

InputStream inStream = new FileInputStream("dynamic.cer");
CertificateFactory cf = CertificateFactory.getInstance("X.509");
X509Certificate cert = (X509Certificate) cf
.generateCertificate(inStream);
ks.setCertificateEntry("dynamic", cert);
inStream.close();

FileOutputStream fos = new FileOutputStream(keyStore);
ks.store(fos, keyStorePassword.toCharArray());
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top