Zimbra offers Open Source email server software and shared calendar for Linux and the Mac
Go Back   Zimbra :: Forums > Zimbra Collaboration Suite > Developers

Welcome to the Zimbra :: Forums!
Welcome, if you would like to post a comment please register. We also encourage you to explore all things Zimbra with our team and members of the community.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-09-2007, 02:07 PM
Special Member
 
Posts: 100
Unhappy SOAP connection URI

Hey Everyone,

I'm working on some software to interface Zimbra and some other systems we run. I made a small test program and I get the following error. I think perhaps I am not connecting the server right port? Any ideas would be great.

The exception and test program are included below.

Code:
XXX@XXX:~$ java -jar ZimbraInterface.jar http://localhost:80 XXX XXXX
Connecting to http://localhost:80 as XXX.... [] INFO: I/O exception (java.net.ConnectException) caught when processing request: Connection refused
[] INFO: Retrying request
[] INFO: I/O exception (java.net.ConnectException) caught when processing request: Connection refused
[] INFO: Retrying request
[] INFO: I/O exception (java.net.ConnectException) caught when processing request: Connection refused
[] INFO: Retrying request
java.net.ConnectException: Connection refused
        at java.net.PlainSocketImpl.socketConnect(Native Method)
        at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
        at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
        at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
        at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
        at java.net.Socket.connect(Socket.java:519)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.commons.httpclient.protocol.ReflectionSocketFactory.createSocket(ReflectionSocketFactory.java:139)
        at org.apache.commons.httpclient.protocol.DefaultProtocolSocketFactory.createSocket(DefaultProtocolSocketFactory.java:124)
        at org.apache.commons.httpclient.HttpConnection.open(HttpConnection.java:706)
        at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:386)
        at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:170)
        at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:396)
        at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:324)
        at com.zimbra.soap.SoapHttpTransport.invoke(SoapHttpTransport.java:192)
        at com.zimbra.soap.SoapTransport.invoke(SoapTransport.java:231)
        at com.zimbra.cs.client.soap.LmcSoapRequest.invoke(LmcSoapRequest.java:148)
        at com.zimbra.cs.client.soap.Test.main(Test.java:57)
Here is the program:
Code:
package com.zimbra.cs.client.soap;

import java.io.IOException;
import java.io.File;
import java.util.*;

import com.zimbra.common.service.ServiceException;
import com.zimbra.cs.client.*;
import com.zimbra.soap.SoapFaultException;
import com.zimbra.cs.index.MailboxIndex;
import com.zimbra.cs.service.mail.ItemAction;
import com.zimbra.cs.util.Zimbra;

public class Test
{
    public static void main(String args[])
    {
        Zimbra.toolSetup();
        if (args.length != 3)
        {
            System.out.println("Usage: Tester <serverURL> <username> <password>");
            System.out.println("where:");
            System.out.println("<serverURL> is the full URL to the SOAP service");
            System.out.println("<username> is the name of the user to log in as");
            System.out.println("<password> is that user's password");
            System.exit(0);
        }
        String serverURL = args[0];
        try
        {
            // ping
            System.out.print("Connecting to " + serverURL + " as " + args[1] + ".... ");
            LmcPingRequest pr = new LmcPingRequest();
            LmcPingResponse pResp = (LmcPingResponse)pr.invoke(serverURL);
            System.out.println("OK");
            
/*            // auth
            System.out.print("connected\nAuthenticating... ");
            LmcAuthRequest auth = new LmcAuthRequest();
            auth.setUsername(args[1]);
            auth.setPassword(args[2]);
            LmcAuthResponse authResp = (LmcAuthResponse)auth.invoke(serverURL);
            LmcSession session = authResp.getSession();
            System.out.println("OK");
/*            
            //get info
            String prefs[] = new String[] { "zimbraPrefMailSignatureEnabled", "zimbraPrefSaveToSent" };
            LmcGetPrefsRequest prefReq = new LmcGetPrefsRequest();
            prefReq.setSession(session);
            prefReq.setPrefsToGet(prefs);
            LmcGetPrefsResponse prefResponse = (LmcGetPrefsResponse)prefReq.invoke(serverURL);
            HashMap prefMap =prefResponse.getPrefsMap();
            Set <String> s = prefMap.entrySet();
            String[] prefStrs = s.toArray(new String[0]);            
            Arrays.sort(prefStrs);
            for(int i = 0; i < prefStrs.length; i++)
                System.out.println(prefStrs[i]);            
            */
        }
        catch (Exception e)
        {
            e.printStackTrace();
        } 
    }
}
Reply With Quote
  #2 (permalink)  
Old 11-09-2007, 02:25 PM
Special Member
 
Posts: 100
Exclamation Update!

I was playing the URL I think I am making progress. Now I am getting a this:

Quote:
Connecting to https://localhost/service/soap as test.... javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException: Untrusted Server Certificate Chain
This kind of makes sense my server has a self signed cert, but I really don't care... Any idea how to allow the connection to proceed? Do I need to modify com.zimbra.soap.SoapHttpTransport.invoke? The full stack trace is below:

Quote:
java -jar ZimbraInterface.jar https://localhost/service/soap test test
Connecting to https://localhost/service/soap as test.... javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException: Untrusted Server Certificate Chain
at com.sun.net.ssl.internal.ssl.Alerts.getSSLExceptio n(Alerts.java:174)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.fatal(S SLSocketImpl.java:1520)
at com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Ha ndshaker.java:182)
at com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Ha ndshaker.java:176)
at com.sun.net.ssl.internal.ssl.ClientHandshaker.serv erCertificate(ClientHandshaker.java:975)
at com.sun.net.ssl.internal.ssl.ClientHandshaker.proc essMessage(ClientHandshaker.java:123)
at com.sun.net.ssl.internal.ssl.Handshaker.processLoo p(Handshaker.java:511)
at com.sun.net.ssl.internal.ssl.Handshaker.process_re cord(Handshaker.java:449)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRec ord(SSLSocketImpl.java:817)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.perform InitialHandshake(SSLSocketImpl.java:1029)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.writeRe cord(SSLSocketImpl.java:621)
at com.sun.net.ssl.internal.ssl.AppOutputStream.write (AppOutputStream.java:59)
at java.io.BufferedOutputStream.flushBuffer(BufferedO utputStream.java:65)
at java.io.BufferedOutputStream.flush(BufferedOutputS tream.java:123)
at org.apache.commons.httpclient.methods.StringReques tEntity.writeRequest(StringRequestEntity.java:150)
at org.apache.commons.httpclient.methods.EntityEnclos ingMethod.writeRequestBody(EntityEnclosingMethod.j ava:495)
at org.apache.commons.httpclient.HttpMethodBase.write Request(HttpMethodBase.java:1973)
at org.apache.commons.httpclient.HttpMethodBase.execu te(HttpMethodBase.java:993)
at org.apache.commons.httpclient.HttpMethodDirector.e xecuteWithRetry(HttpMethodDirector.java:397)
at org.apache.commons.httpclient.HttpMethodDirector.e xecuteMethod(HttpMethodDirector.java:170)
at org.apache.commons.httpclient.HttpClient.executeMe thod(HttpClient.java:396)
at org.apache.commons.httpclient.HttpClient.executeMe thod(HttpClient.java:324)
at com.zimbra.soap.SoapHttpTransport.invoke(SoapHttpT ransport.java:192)
at com.zimbra.soap.SoapTransport.invoke(SoapTransport .java:231)
at com.zimbra.cs.client.soap.LmcSoapRequest.invoke(Lm cSoapRequest.java:148)
at com.zimbra.cs.client.soap.Test.main(Test.java:57)
Caused by: java.security.cert.CertificateException: Untrusted Server Certificate Chain
at com.sun.net.ssl.X509TrustManagerJavaxWrapper.check ServerTrusted(SSLSecurity.java:600)
at com.sun.net.ssl.internal.ssl.ClientHandshaker.serv erCertificate(ClientHandshaker.java:967)
... 21 more
Reply With Quote
  #3 (permalink)  
Old 11-10-2007, 09:45 AM
Zimlet Guru & Moderator
 
Posts: 467
Default

Quote:
Originally Posted by 3RiversTechAdmin View Post
I was playing the URL I think I am making progress. Now I am getting a this:



This kind of makes sense my server has a self signed cert, but I really don't care... Any idea how to allow the connection to proceed? Do I need to modify com.zimbra.soap.SoapHttpTransport.invoke? The full stack trace is below:
Hmm. I thought there was a actual Zimbra connection class that plaed nice with self signed certs. Can't rememberwhere exactly it was, I will try and find it this afternoon.
Reply With Quote
  #4 (permalink)  
Old 12-20-2007, 06:36 AM
Special Member
 
Posts: 100
Smile I'm good

I'm all sorted out. The cert needed to be added to the keystore local to the apps execution environment .
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads

Why Join?

Registering let's you ask questions, makes it easier to search, displays any files attached to posts, and notifies you about replies.

blog.zimbra.com




 

SEO by vBSEO ©2011, Crawlability, Inc.