Hi,
I have an application which does some web service calls over SSL.
When the application does a web service call to a server which I don't
have the certificate in the keystore, I get an exception, which is ok.
Is there a way I can add the certificate to the keystore at runtime and
then do the web service call again?
I tried to add it using code like the following:
...
KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType());
...
ks.load(new FileInputStream(ksf), pw);
...
ks.setCertificateEntry(alias,
CertificateFactory.getInstance("X.509").generateCertificate(new
FileInputStream(certFile)));
...
ks.store(new FileOutputStream(ksf), pw);
But the above does not work (the certificate is only active after I
restart my application), and I think its because te KeyStore.getInstance
methode returns a -new- instance, not the one being currenlty used by
Java's SSL classes.
Can anyone help me with this?
Thanks.
Andre.
Pankaj Kumar - 11 Oct 2003 09:10 GMT
Take a look at the javax.net.ssl.KeyManagerFactory class. This class
is initialized with a KeyStore. If you initilize a KeyFactoryManager
with a particular instance of KeyStore and specify this
KeyFactoryManager to be used, then perhaps the additions to the
KeyStore will get reflected at runtime.
Pankaj Kumar.