Set a KeyStore as the system property javax.net.ssl.trustStore value

O

oziris

[CC from comp.lang.java.security]

Hi,

Here the deal.
- I know how to create a KeyStore with KeyStore.getInstance(), etc.
- I know how to set a keystore file (.keystore) as the value of the
system property javax.net.ssl.trustStore with System.setProperty().

Is there a mean to set a KeyStore object as the this property value?

My application has only access to the certificate files and I would
like dynamically create a KeyStore, set the above property with in
order to create a SSL session only with the instruction

m_sslSession = new URL("https://localhost:443/soap/servlet/rpcrouter");

so without using SSLContext and SSLSocketFactory.

Thanks in advance even for any minor births of ideas you could have.

-o--
 
R

Roedy Green

Is there a mean to set a KeyStore object as the this property value?

when you dynamically change a system property you are giving the
property a string value, so obviously you can't set a property to an
object. It might be set to a file name, an URL etc. But of course
the meaning of the property is defined and if you put something other
than the original sort of value in there, it won't work.

Sun has a habit of giving a two or three techniques to register a
plug-in replacement: a system property, a magic jar entry, and a
static register method. Perhaps you should look for one of the other
two.
 
O

oziris

thanks for your help roedy. Could you precise what mean "static
register method"? That seams to be a suitable solution.

-o--
 
R

Roedy Green

thanks for your help roedy. Could you precise what mean "static
register method"? That seams to be a suitable solution.

For example in JCE if you have wrote a new provider class you can
register it by called a method with a name something
registerNewJCEProvider ( JCEProviderInterface j );

I thought there might be an equivalent for your problem.

You can register new encodings with a scheme like this:
A charset provider identifies itself with a provider-configuration
file named java.nio.charset.spi.CharsetProvider in the resource
directory META-INF/services. The file should contain a list of
fully-qualified concrete charset-provider class names, one per line. A
line is terminated by any one of a line feed ('\n'), a carriage return
('\r'), or a carriage return followed immediately by a line feed.
Space and tab characters surrounding each name, as well as blank
lines, are ignored. The comment character is '#' ('\u0023'); on each
line all characters following the first comment character are ignored.
The file must be encoded in UTF-8.


Preferences has a plug-in registration scheme that works like this:
If a PreferencesFactory implementation class file has been installed
in a jar file that is visible to the system class loader, and that jar
file contains a provider-configuration file named
java.util.prefs.PreferencesFactory in the resource directory
META-INF/services, then the first class name specified in that file is
taken.
 

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

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top