Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Security / October 2003

Tip: Looking for answers? Try searching our database.

adding new certificate to keystore

Thread view: 
Andre Charbonneau - 10 Oct 2003 15:38 GMT
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.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.