WEBDAV throught SSL

Hi,ALL

I write a client source.

I want to use webDAV to access Exchange public folder

Customer public folder security setting is SSL enable.

So I my httpClient also should be SSL Enable.

I have my source:

String personalURL = "http://172.16.0.20:8988/public/";

XMLResponseMethodBase method = null;

try{

// SSL

// jdk 1.4

try{

String secProviderName = "com.sun.crypto.provider.SunJCE";

java.security.Provider secProvider =

(java.security.Provider)Class.forName(secProviderName).newInstance();

Security.addProvider(secProvider);

}catch(Exception ex){

System.out.println(ex.toString());

}

// if want to going throught https: it is supposed to add the following Provider

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

NTCredentials creds = new NTCredentials("8700@mydomain.com", "test", "172.16.0.20:8988", "");

setState(new WebdavState());

HostConfiguration hostConfig = getHostConfiguration();

HttpState clientState = getState();

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

clientState.setAuthenticationPreemptive(true);

setConnectionTimeout(120000);

method = new SearchMethod(URIUtil.encodePathQuery(personalURL));

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(false);

int result = executeMethod(method);

Document m_doc = method.getResponseDocument();

method.releaseConnection();

}catch(Exception ex)

{

System.out.println(ex.toString());

}

The problem is:

when I set String personalURL = "http://172.16.0.20:8988/public/";

it gives me an exception:

Jun 9, 2006 11:43:06 AM org.apache.commons.httpclient.HttpMethodBase readResponseBody

WARNING: Response content length is not known

Jun 9, 2006 11:43:06 AM org.apache.commons.httpclient.HttpMethodBase processRedirectResponse

INFO: Redirect requested but followRedirects is disabled

if I set String personalURL = "https://172.16.0.20:8988/public/";

I get the following exception:

javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?

any suggestion would be great accepted

[2547 byte] By [lvguangchuana] at [2007-10-2 22:09:46]
# 1
This could shed some light: http://mail-archives.apache.org/mod_mbox/jakarta-httpclient-dev/200408.mbox/%3C825BF35A92B3F0479CC164ECBBE9376EE3B6FF@kccxoex06.corp.kpmgconsulting.com%3E
gugo46a at 2007-7-14 1:26:34 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 2

Just in case anyone is searching for an answer on this problem:

if you get the error 'Redirect requested but followRedirects is disabled' this is probably because Exchange is trying to redirect the request to SSL. This is the default behaviour for Exchange 2003.

You'll see this if you allow redirects in your request - for example, if you are using Slide then use this constructor:

WebdavResource(HttpURL httpURL, boolean followRedirects)

You can configure Exchange so that it doesn't require SSL - note that you have to do this seperately for the 'websites' Exchange and Public.

MartinWa at 2007-7-14 1:26:34 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...