Hi
I have xml-rpc running in tomcat server. I have enabled https. I want to access it over https but Im getting error on client side. IO am running client using following command
%JAVA_HOME%\bin\java -cp classes;%JARS%
com.edb.usm.test.SecureXmlRpcTest https://localhost 8443 .keystore changeit
where %JAR% contains reference to
commons-codec-1.3.jar;commons-httpclient-3.0.1.jar;commons-logging-1.0.4.jar
;edb-commons.jar;ws-commons-util.jar;xmlrpc-3.0a1.jar;xmlrpc-1.2-b1.jar
and getting following error.
java.io.IOException: sun.security.validator.ValidatorException: No trusted certificate found
java.io.IOException
: sun.security.validator.ValidatorException: No trusted certificate found
at org.apache.xmlrpc.XmlRpcClient$Worker.execute(XmlRpcClient.java:444)
at org.apache.xmlrpc.XmlRpcClient.execute(XmlRpcClient.java
:163)
at com.edb.usm.test.SecureXmlRpcTest.main(SecureXmlRpcTest.java:98)
Can Any one help me on this
My client programm is
/********************************************************************************************************************/
/**
* $Id: SecureXmlRpcTest.java,v 1.1 2003/12/10 18:49:22 dkha Exp $
*/
package com.edb.usm.test;
import java.util.Vector;
import java.io.IOException;
import java.io.FileInputStream;
import java.net.MalformedURLException;
import java.security.KeyStore;
import java.security.NoSuchAlgorithmException;
import java.security.KeyStoreException;
import java.security.KeyManagementException;
import
java.security.UnrecoverableKeyException;
import java.security.cert.CertificateException;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSocketFactory;
import
javax.net.ssl.KeyManagerFactory;
import javax.net.ssl.TrustManagerFactory;
import org.apache.xmlrpc.XmlRpcException;
import org.apache.xmlrpc.secure.SecureXmlRpcClient;
import org.apache.xmlrpc.secure.SecurityTool
;
/**
* Tests a secure XML-RPC call (using Apache XML-RPC).
*
* @version $Revision: 1.1 $
* @author Daniel Kha, <a href="" href="mailto:[EMAIL PROTECTED]">[EMAIL PROTECTED]">
[EMAIL PROTECTED]</a>
*/
public class SecureXmlRpcTest {
public static final String SECURE_ALGORITHM = "SunX509";
public static final String SECURE_PROTOCOL = "SSL";
public static final String KEYSTORE_TYPE = "JKS";
public static SSLSocketFactory getSSLSocketFactory(String keyStoreFilename,
String keyStorePassword)
throws NoSuchAlgorithmException, KeyStoreException,
CertificateException, UnrecoverableKeyException,
KeyManagementException, IOException {
char[] keyStorePasswordCharArray = keyStorePassword.toCharArray();
KeyStore ks = KeyStore.getInstance(KEYSTORE_TYPE);
ks.load(new FileInputStream(keyStoreFilename),
keyStorePasswordCharArray);
KeyManagerFactory kmf =
KeyManagerFactory.getInstance(SECURE_ALGORITHM);
kmf.init(ks, keyStorePasswordCharArray);
TrustManagerFactory tmf =
TrustManagerFactory.getInstance(SECURE_ALGORITHM);
tmf.init(ks);
SSLContext sslCtx = SSLContext.getInstance(SECURE_PROTOCOL);
sslCtx.init(kmf.getKeyManagers(), tmf.getTrustManagers
(), null);
return(sslCtx.getSocketFactory());
}
public static void main(String[] args) {
if (args.length < 4) {
System.out.println("Usage: java SecureXmlRpcTest <host> <port> <keystore> <keystorePassword>");
System.exit(0);
}
String host = args[0];
int port = 0;
try {
port = Integer.parseInt(args[1]);
} catch (NumberFormatException e) {
System.out.println("Using default port = "+port);
}
String keyStoreFilename = args[2];
String keyStorePassword = args[3];
try {
SSLSocketFactory socketFactory = getSSLSocketFactory(
keyStoreFilename, keyStorePassword);
HttpsURLConnection.setDefaultSSLSocketFactory(socketFactory);
SecureXmlRpcClient client = new SecureXmlRpcClient(host, port);
// Fill in the appropriate method call that's available on your
// server.
String method = "Service.methodName";
// Set the appropriate parameters
Vector paramsVector = new Vector();
// Here I am adding parameters for method
paramsVector.addElement( new Object);
Object result = client.execute(method, paramsVector);
System.out.println("XML-RPC result = "+result);
} catch (XmlRpcException e) {
System.err.println(e);
e.printStackTrace();
} catch (MalformedURLException e) {
System.err.println(e);
e.printStackTrace();
} catch (IOException e) {
System.err.println(e);
e.printStackTrace();
} catch (Exception e) {
System.err.println(e);
e.printStackTrace();
}
}
}
/********************************************************************************************************************/
- XML-RPC over SSL Rafaqat Ali
- Re: XML-RPC over SSL Jochen Wiedmann
- Re: XML-RPC over SSL Rafaqat Ali
- Re: XML-RPC over SSL Rafaqat Ali
- Re: XML-RPC over SSL Jochen Wiedmann
- Re: XML-RPC over SSL Rafaqat Ali
- Re: XML-RPC over SSL Jochen Wiedmann
- RE: XML-RPC over SSL Zhou, Jing (Jing)
- Re: XML-RPC over SSL Jochen Wiedmann
- RE: XML-RPC over SSL Zhou, Jing (Jing)
