> I'm attempting to connect to a server via HTTPS from a Java client.
> I have downloaded the server's certificate using IE and saved it in a
[quoted text clipped - 10 lines]
> -Djavax.net.ssl.keyStore=/path/to/.keystore
> -Djavax.net.ssl.keyStorePassword=***
All the above should refer to 'truststore' instead of 'keystore'
including the system property name. A keystore is a source for your
*own* cert when sending to others; a truststore is a place to check
incoming certs against.
> I have also tried putting
> -Djavax.net.ssl.trustStore=/usr/java/jdk1.5.0_06/jre/lib/security/cacerts
> -Djavax.net.ssl.trustStorePassword=***
> on the command line -- no effect. What else can I try?
But have you put the server's cert into there? That's where it belongs.
> java.security.Security.setProperty ("ssl.SocketFactory.provider",
> "my.customFactory");
>
> and also tried -Dssl.SocketFactory.provider=my.customFactory, both
> to no effect. What else can I try here?
You don't need to do this. Just get yourself an SSLContext and
initialize it appropriately with implementations of your own
TrustManager, then get your SSLSocketFactory/SSLServerSocketFactory from
that SSLContext. There's some guidance on this in the Javadoc Guide to
Features/Security/JSSE Reference.
Rogan Dawes - 21 Jun 2006 08:22 GMT
>> I'm attempting to connect to a server via HTTPS from a Java client.
>> I have downloaded the server's certificate using IE and saved it in a
[quoted text clipped - 34 lines]
> that SSLContext. There's some guidance on this in the Javadoc Guide to
> Features/Security/JSSE Reference.
For what it is worth, there is a short program demonstrating various
aspects of the Java SSL implementation (with some 1.5 specific features)
on my website at <http://dawes.za.net/rogan/PKCS11Test.java>
It demonstrates using a PKCS#11 provider, using a TrustManager, using a
KeyManager, using a HostnameVerifier, etc.
Some of it may be useful to you.
However, I think that EJP's hit the nail on the head, with the
truststore vs keystore.
Rogan