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());
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());