You are viewing a plain text version of this content. The canonical link for it is here.
Posted to slide-user@jakarta.apache.org by Koch Christoph <Ch...@axentiv.de> on 2006/08/18 10:52:00 UTC

Problem with SSL and Slide: javax.net.ssl.SSLHandshakeException

Hi all,

I have got a problem using my Slide client application over SSL. It
works fine with http, but when the WebDav server can only be reached via
SSL I get an exception in my Slide client application: 
javax.net.ssl.SSLHandshakeException

Can someone point me to the correct documentation on how I can configure
the SSL certificates between my WAS where the application is and the
WEBDAV server?
By the way both servers are SAP Web Application Servers 6.40.


Kind regards,
Christoph


---------------------------------------------------------------------
To unsubscribe, e-mail: slide-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: slide-user-help@jakarta.apache.org


Re: Problem with SSL and Slide: javax.net.ssl.SSLHandshakeException

Posted by ZacWolf <za...@zacwolf.com>.
I was seeing a similar issue and tracked the problem down to the fact that
the webDAV server I was trying to connect to was using a "non-standard CA
Authority" for generating it's SSL certficate.  This means that the defaults
that the java SSL classes uses couldn't verify the root authority.

I wrote my own handler that would auto-trust whatever CA authority generated
the root certificate, and it works fine now.  This is fine if you know and
trust the "end point" but isn't recommended for solutions where the end
point is runtime defined.

<hr>
Protocol.registerProtocol( "https", new Protocol( "https", new
AllTrustedSSLProtocolSocketFactory(), 443));
<hr>
package com.cisco.ctaps.presence.util.ssl;

import java.io.*;
import java.net.*;
import javax.net.ssl.*;

import org.apache.commons.httpclient.protocol.SecureProtocolSocketFactory;
import org.apache.commons.logging.*;

public class AllTrustedSSLProtocolSocketFactory implements
SecureProtocolSocketFactory{
	private static final	Log				LOG			=
LogFactory.getLog(AllTrustedSSLProtocolSocketFactory.class);
	private 				SSLContext		sslcontext	=	null;

	public AllTrustedSSLProtocolSocketFactory() {
		super();
	}

	private static SSLContext createAllTrustedSSLContext() {
		TrustManager[] trustAllCerts	=	new TrustManager[] {
			new X509TrustManager() {
				public java.security.cert.X509Certificate[] getAcceptedIssuers() {
					return null;
				}

				public void checkClientTrusted(
					java.security.cert.X509Certificate[] certs, String authType) {
				}

				public void checkServerTrusted(
					java.security.cert.X509Certificate[] certs, String authType) {
				}
			}
		};

		try {
			SSLContext	context			=	SSLContext.getInstance("SSL");
						context.init(null,trustAllCerts,null);
			return context;
		} catch (Exception e) {
			LOG.error(e.getMessage(), e);
			throw new RuntimeException( e);
		}
	}

	private SSLContext getSSLContext() {
		if (this.sslcontext == null) {
			this.sslcontext = createAllTrustedSSLContext();
		}
		return this.sslcontext;
	}

	public Socket createSocket(String host,int port,InetAddress clientHost,int
clientPort)throws IOException, UnknownHostException {
		return
getSSLContext().getSocketFactory().createSocket(host,port,clientHost,clientPort);
	}

	public Socket createSocket(String host, int port) throws IOException,
UnknownHostException {
		return getSSLContext().getSocketFactory().createSocket(host,port);
	}

	public Socket createSocket(Socket socket,String host,int port,boolean
autoClose)throws IOException, UnknownHostException {
		return
getSSLContext().getSocketFactory().createSocket(socket,host,port,autoClose);
	}

	public boolean equals(Object obj) {
		return ((obj != null) &&
obj.getClass().equals(AllTrustedSSLProtocolSocketFactory.class));
	}

	public int hashCode() {
		return AllTrustedSSLProtocolSocketFactory.class.hashCode();
	}
}
<hr>

Koch Christoph wrote:
> 
> Hi all,
> 
> I have got a problem using my Slide client application over SSL. It
> works fine with http, but when the WebDav server can only be reached via
> SSL I get an exception in my Slide client application: 
> javax.net.ssl.SSLHandshakeException
> 
> Can someone point me to the correct documentation on how I can configure
> the SSL certificates between my WAS where the application is and the
> WEBDAV server?
> By the way both servers are SAP Web Application Servers 6.40.
> 
> 
> Kind regards,
> Christoph
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: slide-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: slide-user-help@jakarta.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Problem-with-SSL-and-Slide%3A-javax.net.ssl.SSLHandshakeException-tf2126100.html#a5998565
Sent from the Jakarta Slide - User forum at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: slide-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: slide-user-help@jakarta.apache.org