SSL question

Hi,ALL

I am new to Security.

One of my customer's public folder is ssl enabled.

So when I use Java httpclient to build a connection with the public folder.

https://server/public

It throws and exception:

javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: No trusted certificate found

The question is:

Have I to get a client certificate from Server?

I want to do like IE, when I browser public folder with ssl enabled.

It will pop up a dialog to ask you to trust or not.

How to implement this ?

Thanks.

here is my code

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

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

System.setProperty("javax.net.ssl.trustStore","E:\\Program Files\\jdev1012\\jdk\\jre\\lib\\security\\cacerts");

System.setProperty("javax.net.ssl.trustStorePassword","changeit");

NTCredentials creds =new NTCredentials("administrator","password","172.16.0.20","");

setState(new WebdavState());

HttpState clientState = getState();

clientState.setCredentials(null,"172.16.0.20",creds);

//getHostConfiguration().setHost("172.16.0.20", 443, protocol);

method =new SearchMethod("https://172.16.0.20/public/Manager");

method.setDebug(3);

method.setRequestHeader("Translate","f");

method.setRequestHeader("Content-Type","text/xml");

method.setRequestHeader("Depth","1");

method.setRequestHeader("Content-Length","" + query.length());

method.setRequestBody(query);

method.setFollowRedirects(true);

int result = executeMethod(method);

Document m_doc = method.getResponseDocument();

method.releaseConnection();

}catch(Throwable ex)

{

ex.printStackTrace();

}

[2745 byte] By [lvguangchuana] at [2007-10-3 0:31:05]
# 1

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

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

From JDK 1.4.0 onwards the above is all redundant.

System.setProperty("javax.net.ssl.trustStore", "E:\\Program Files\\jdev1012\\jdk\\jre\\lib\\security\\cacerts");

This is always redundant, that's the default.

System.setProperty("javax.net.ssl.trustStorePassword", "changeit");

This is unnecessary: JSSE doesn't really need the truststore password.

What you have is a server certificate that isn't recognized because it isn't in your truststore. You either have to create a new truststore containing the server certificate and point JSSE to that truststore (best done by calling it jssecacerts and installing it in the same place as cacerts), or import the server certificate into cacerts directly if you can stand it.

ejpa at 2007-7-14 17:24:14 > top of Java-index,Security,Other Security APIs, Tools, and Issues...
# 2
Thanks ejp.One more question.>>or import the server certificate into cacerts directly if you can stand it. Does it mean that I get a certificate from server, and use keytool to register it to truststore?Thanks again
lvguangchuana at 2007-7-14 17:24:14 > top of Java-index,Security,Other Security APIs, Tools, and Issues...
# 3
yes
ejpa at 2007-7-14 17:24:14 > top of Java-index,Security,Other Security APIs, Tools, and Issues...