ws-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Starsscream Desepticon <kastanienr...@yahoo.co.uk>
Subject Still getting unknown certificate Exception
Date Mon, 26 Sep 2005 11:09:40 GMT
Hi

I'm still getting: 

javax.net.ssl.SSLHandshakeException: Received fatal
alert:
certificate_unknown
javax.net.ssl.SSLHandshakeException: Received fatal
alert:
certificate_unknown

This workaround is not working, it still doesn't
accept my selfsigned
certificates. Does anyone know what the problem is?
Complete code is
below.


Thank you



import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLSession;

public class MyHostnameVerifier implements
HostnameVerifier {

        public boolean verify(String urlHostName,
SSLSession session) {
                if
(urlHostName.equals(session.getPeerHost())) {
                        return true;
                } else {
                        System.out.println(urlHostName
+ " and " + session.getPeerHost());
                        return false;
                }
        }
} // end of class



import java.security.cert.X509Certificate;

import javax.net.ssl.X509TrustManager;

public class MyTrustManager implements
X509TrustManager {
        
    public void checkClientTrusted(X509Certificate[]
chain, String
authType) {
    }
    
    public void checkServerTrusted(X509Certificate[]
chain, String
authType) {
    }
    
    public X509Certificate[] getAcceptedIssuers() {
        return null;
    }
} // end of class



import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Vector;

import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
import javax.net.ssl.X509TrustManager;

import org.apache.xmlrpc.AuthenticatedXmlRpcHandler;
import org.apache.xmlrpc.secure.SecureWebServer;
import org.apache.xmlrpc.secure.SecurityTool;

public class SecureServer {
        
        private SecureWebServer secureWebServer;

        private class TestHandler implements
AuthenticatedXmlRpcHandler {

                public Object execute(String method,
Vector param, String user,
                                String pwd) {
                        System.out.println(method);
                        if (method.equals("test")) {
                                return "hello world";
                        }
                }
        }

        public SecureServer() {
                try {
                        
                       
SecurityTool.setKeyStore("KEYSTORE");
                       
SecurityTool.setKeyStorePassword(PWD);
                        
                        SSLContext sslctx =
SSLContext.getInstance("SSL");
                        sslctx.init(null, new
X509TrustManager[] { new MyTrustManager() },
null);

HttpsURLConnection.setDefaultSSLSocketFactory(sslctx.getSocketFactory());
                       
HttpsURLConnection.setDefaultHostnameVerifier(new
MyHostnameVerifier());
                        
                        secureWebServer = new
SecureWebServer(2000);
                       
secureWebServer.addHandler("testhandler", new
TestHandler());
                        secureWebServer.start();
                } catch (Exception e) {
                        e.printStackTrace();
                }
        } // end of class



import java.util.Vector;

import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
import javax.net.ssl.X509TrustManager;

import org.apache.xmlrpc.secure.SecureXmlRpcClient;
import org.apache.xmlrpc.secure.SecurityTool;


public class SecureClient {

        public SecureClient() {
                try {
                        
                       
SecurityTool.setKeyStore("KEYSTORE");
                       
SecurityTool.setKeyStorePassword(PWD);
                        SecurityTool.setup();
                        
                        SSLContext sslctx =
SSLContext.getInstance("SSL");
                        sslctx.init(null, new
X509TrustManager[] { new MyTrustManager() },
null);

HttpsURLConnection.setDefaultSSLSocketFactory(sslctx.getSocketFactory());
                       
HttpsURLConnection.setDefaultHostnameVerifier(new
MyHostnameVerifier());
                        
                        SecureXmlRpcClient
secureXmlRpcClient = new SecureXmlRpcClient(
                                       
"https://localhost:2000/");
                
                        String answer = (String)
secureXmlRpcClient.execute(
                                       
"testhandler.test", new Vector());
                        System.out.println(answer);
                } catch (Exception e) {
                        e.printStackTrace();
                }
        }
    public static void main(String[] args) {
        SecureClient secureClient = new
SecureClient();
    }
} // end of class




		
___________________________________________________________ 
To help you stay safe and secure online, we've developed the all new Yahoo! Security Centre.
http://uk.security.yahoo.com

Mime
View raw message