Newbie to JSSE && HttpsURLConnection

The included code throws this exception:

com.dstc.security.util.ConfigException: property file ssl.properties not found

at com.dstc.security.util.Config.getProperties(Config.java:84)

at com.dstc.security.ssl.SSLSocketFactory.initializeKeys(SSLSocketFactory.java:104)

at com.dstc.security.ssl.SSLSocketFactory.<init>(SSLSocketFactory.java:95)

at com.dstc.security.ssl.SSLSocketFactory.<clinit>(SSLSocketFactory.java:78)

at javax.net.ssl.SSLSocketFactory.getDefault(SSLSocketFactory.java:63)

at com.sun.net.ssl.HttpsURLConnection.<clinit>([DashoPro-V1.2-120198])

at com.sun.net.ssl.internal.www.protocol.https.Handler.openConnection([DashoPro-V1.2-120198])

at java.net.URL.openConnection(URL.java:781)

at com.HTTPSTest.main(HTTPSTest.java:41)

Exception whilst loading data from the URL: java.lang.NullPointerException

Any help would be greatly appreciated.

Code:publicstaticvoid main(String[] args)throws Exception{

String url ="https://theyhaveit.com/";

java.security.Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider() );

System.setProperty ("java.protocol.handler.pkgs","com.sun.net.ssl.internal.www.protocol");

URL urlLink;

InputStream tempStream;

HttpsURLConnection huc;

boolean isFormPage =false;

try{

urlLink = HTMLUtilities.createURL(url);

huc = (HttpsURLConnection) urlLink.openConnection();// line #41

huc.setUseCaches(false);

huc.setDefaultUseCaches(false);

tempStream = huc.getInputStream();

}catch (Exception e){

System.out.println(" Exception whilst loading data from the URL: " + e);

}

return;

}

[2463 byte] By [viiviiviivii] at [2007-9-26 4:27:34]
# 1

What version of JSSE are you using ?

Also, have you configured the provider into the security property file ?

See http://java.sun.com/products/jsse/doc/guide/API_users_guide.html

and look for the phrase Registering the Cryptographic Service Provider Statically

neville_sequeira at 2007-6-29 17:37:24 > top of Java-index,Security,Java Secure Socket Extension (JSSE)...
# 2

I am using jsse 1.0.2,

I am also defining dynamically:

Security.addProvider(new sun.security.provider.Sun());

Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());

System.setProperty ("java.protocol.handler.pkgs", "com.sun.net.ssl.internal.www.protocol");

I wonder if it has something to do with ssl.properties? Any ideas? Have you gotten similar code to work?

Thanks

viiviiviivii at 2007-6-29 17:37:24 > top of Java-index,Security,Java Secure Socket Extension (JSSE)...
# 3

<< I am using jsse 1.0.2

Are you using JSSE 1.0.2 API and the reference implementation (the provider etc.) that comes with it ? That is what is looks like from your code. i.e. you are setting provider etc, from the code itself.

However, from the exception, it looks like you have installed some other security provider on your machine and maybe configured this provider into your java.security file. Am I right ? At this point, this is only a guess.

However, if I have guessed correctly, and you want to use JSSE 1.0.2 reference implementation, remove that other provider specification from your java.security file.

Let us know if this does not work.

neville_sequeira at 2007-6-29 17:37:24 > top of Java-index,Security,Java Secure Socket Extension (JSSE)...
# 4

I have about 4 jre's on my machine.. but, I have made sure that all of the /lib/security/java.security files contain:

security.provider.1=sun.security.provider.Sun

security.provider.2=com.sun.net.ssl.internal.ssl.Provider

I have set the property:

-Djava.protocol.handler.pkgs=com.sun.net.ssl.internal.www.protocol

so it is runtime, rather than dynamic.

I still get this exception:

com.dstc.security.util.ConfigException: property file ssl.properties not found

at com.dstc.security.util.Config.getProperties(Config.java:84)

at com.dstc.security.ssl.SSLSocketFactory.initializeKeys(SSLSocketFactory.java:104)

at com.dstc.security.ssl.SSLSocketFactory.<init>(SSLSocketFactory.java:95)

at com.dstc.security.ssl.SSLSocketFactory.<clinit>(SSLSocketFactory.java:78)

at javax.net.ssl.SSLSocketFactory.getDefault(SSLSocketFactory.java:63)

at com.sun.net.ssl.HttpsURLConnection.<clinit>([DashoPro-V1.2-120198])

at com.sun.net.ssl.internal.www.protocol.https.Handler.openConnection([DashoPro-V1.2-120198])

at java.net.URL.openConnection(URL.java:781)

at java.net.URL.openStream(URL.java:798)

at com.HTTPSTest.main(HTTPSTest.java:36)

java.lang.NullPointerException

at com.dstc.security.ssl.HandShaker.setEnabledCipherSuites(HandShaker.java:299)

at com.dstc.security.ssl.SSLSocket.setEnabledCipherSuites(SSLSocket.java:175)

at com.dstc.security.ssl.SSLSocket.<init>(SSLSocket.java:90)

at com.dstc.security.ssl.BaseSSLSocketFactory.createSocket(BaseSSLSocketFactory.java:101)

at com.sun.net.ssl.internal.www.protocol.https.HttpsClient.doConnect([DashoPro-V1.2-120198])

at com.sun.net.ssl.internal.www.protocol.https.NetworkClient.openServer([DashoPro-V1.2-120198])

at com.sun.net.ssl.internal.www.protocol.https.HttpClient.l([DashoPro-V1.2-120198])

at com.sun.net.ssl.internal.www.protocol.https.HttpClient.<init>([DashoPro-V1.2-120198])

at com.sun.net.ssl.internal.www.protocol.https.HttpsClient.<init>([DashoPro-V1.2-120198])

at com.sun.net.ssl.internal.www.protocol.https.HttpsClient.a([DashoPro-V1.2-120198])

at com.sun.net.ssl.internal.www.protocol.https.HttpsClient.a([DashoPro-V1.2-120198])

at com.sun.net.ssl.internal.www.protocol.https.HttpsURLConnection.connect([DashoPro-V1.2-120198])

at com.sun.net.ssl.internal.www.protocol.https.HttpsURLConnection.getInputStream([DashoPro-V1.2-120198])

at java.net.URL.openStream(URL.java:798)

at com.HTTPSTest.main(HTTPSTest.java:36)

I have printed out a stacktrace at the end of the exception.

Hmm.. still quite strange.. does anyone out there have a working Https URL Connection?

viiviiviivii at 2007-6-29 17:37:24 > top of Java-index,Security,Java Secure Socket Extension (JSSE)...
# 5

<< does anyone out there have a working Https URL Connection?

Ofcourse. For me, all the examples that come with JSSE do work. And I am positive about that.

<< I have made sure that all of the /lib/security/java.security files contain:

<< security.provider.1=sun.security.provider.Sun

<< security.provider.2=com.sun.net.ssl.internal.ssl.Provider

This may sound very frustrating. But how sure are you about this ?

For example, in my machine, I have to setup the providers in the file D:\Program Files\JavaSoft\JRE\1.3.1\lib\security\java.security

I think its very visible from your exception that somehow the provider that comes with a product called JCSI ( i.e. Java Crypto and Security Implementation) is being used in your runtime.

neville_sequeira at 2007-6-29 17:37:24 > top of Java-index,Security,Java Secure Socket Extension (JSSE)...
# 6

It's working!!!!

Thankyou for your help...

It so turned out that sometime last year myself or one of my coworkers included jcsi.jar into our packages list. This 'lil ****** turned out to be the cause of all of my problems.

I should have looked at my jar files earler (I apologize if someone has already told me to do that).. Anyway, now I am trying to find out why on earth that jar file was included!!

Thanks again!

viiviiviivii at 2007-6-29 17:37:24 > top of Java-index,Security,Java Secure Socket Extension (JSSE)...