You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@ws.apache.org by Rafaqat Ali <sm...@gmail.com> on 2006/07/28 16:51:52 UTC

XML-RPC over SSL

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="mailto:dkha@yorku.ca">dkha@yorku.ca</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();
        }
    }
}

/********************************************************************************************************************/

Re: XML-RPC over SSL

Posted by Rafaqat Ali <sm...@gmail.com>.
It is now working if I enter localhost against firstname and last name when
executing command
%JAVA_HOME%\bin\keytool -genkey -alias tomcat -keyalg RSA
And when I run client using localhost on local machine it works fine.
but when I try to access it with ip address it doesn't work even I tried to
put my machine's ip in first name and last name
I use following command to run program
java -cp classes;%JARS% com.edb.usm.test.SecureXmlRpcTest 10.90.1.124 8443
"C:\Documents and Settings\rafaqat\.keystore" changeit

but it thorws Exception

java.io.IOException: HTTPS hostname wrong:  should be <10.90.1.124>
java.io.IOException: HTTPS hostname wrong:  should be <10.90.1.124>
        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:116)

and in (SecureXmlRpcTest.java at line 116 I am calling execute method as
            Object result = client.execute(method, paramsVector);



On 7/30/06, Jochen Wiedmann <jo...@gmail.com> wrote:
>
> Rafaqat Ali wrote:
> > java.io.IOException: Server returned HTTP response code: 405 for URL:
> > https://lo
> > calhost:8443/edb/
> >         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:99)
>
> Servers log file?
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xmlrpc-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: xmlrpc-user-help@ws.apache.org
>
>

Re: XML-RPC over SSL

Posted by Jochen Wiedmann <jo...@gmail.com>.
Rafaqat Ali wrote:
> java.io.IOException: Server returned HTTP response code: 405 for URL: 
> https://lo
> calhost:8443/edb/
>         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:99)

Servers log file?


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


Re: XML-RPC over SSL

Posted by Rafaqat Ali <sm...@gmail.com>.
Sorry I am creating client as
SecureXmlRpcClient client = new SecureXmlRpcClient("
https://localhost:8443/edb <https://localhost:8443/xmlrpc>");
And here my service is deployed

On 7/30/06, Rafaqat Ali <sm...@gmail.com> wrote:
>
> Hi
>     I tried this and while creating client I am using
> SecureXmlRpcClient client = new SecureXmlRpcClient("
> https://localhost:8443/xmlrpc");
> after execution I am getting
>
> java.io.IOException: Server returned HTTP response code: 405 for URL:
> https://lo
> calhost:8443/edb/
>
>         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
> :99)
>
> Yes it is true. In case of normal execution when I enter webservice URL in
> browser it shows
> HTTP Status 405 - HTTP method GET is not supported by this URL
> and in my application it works fine.
>
> But in case of secure execution it throws Exception. Any help ????
>
> Regards
> Rafaqat Ali
>
>
>
> On 7/29/06, Jochen Wiedmann < jochen.wiedmann@gmail.com> wrote:
> >
> > On 7/28/06, Rafaqat Ali < smoken0@gmail.com> wrote:
> >
> > >     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
> >
> > See
> >
> >     http://ws.apache.org/xmlrpc/ssl.html
> >
> >
> > --
> > My wife Mary and I have been married for forty-seven years and not
> > once have we had an argument serious enough to consider divorce;
> > murder, yes, but divorce, never.
> > (Jack Benny)
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: xmlrpc-user-unsubscribe@ws.apache.org
> > For additional commands, e-mail: xmlrpc-user-help@ws.apache.org
> >
> >
>

Re: XML-RPC over SSL

Posted by Rafaqat Ali <sm...@gmail.com>.
Hi
    I tried this and while creating client I am using
SecureXmlRpcClient client = new SecureXmlRpcClient("
https://localhost:8443/xmlrpc");
after execution I am getting

java.io.IOException: Server returned HTTP response code: 405 for URL:
https://lo
calhost:8443/edb/
        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:99)

Yes it is true. In case of normal execution when I enter webservice URL in
browser it shows
HTTP Status 405 - HTTP method GET is not supported by this URL
and in my application it works fine.

But in case of secure execution it throws Exception. Any help ????

Regards
Rafaqat Ali


On 7/29/06, Jochen Wiedmann <jo...@gmail.com> wrote:
>
> On 7/28/06, Rafaqat Ali <sm...@gmail.com> wrote:
>
> >     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
>
> See
>
>     http://ws.apache.org/xmlrpc/ssl.html
>
>
> --
> My wife Mary and I have been married for forty-seven years and not
> once have we had an argument serious enough to consider divorce;
> murder, yes, but divorce, never.
> (Jack Benny)
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xmlrpc-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: xmlrpc-user-help@ws.apache.org
>
>

Re: XML-RPC over SSL

Posted by Jochen Wiedmann <jo...@gmail.com>.
On 7/28/06, Rafaqat Ali <sm...@gmail.com> wrote:

>     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

See

    http://ws.apache.org/xmlrpc/ssl.html


-- 
My wife Mary and I have been married for forty-seven years and not
once have we had an argument serious enough to consider divorce;
murder, yes, but divorce, never.
(Jack Benny)

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