You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by Marco Geirola <m....@set-network.com> on 2008/09/05 10:02:46 UTC

HttpClient SSL AUTHENTICATION PROBLEM

Hi,

I'm tring to connect to a server over HTTPS protocol but I cannot 
authenticate the client.
I can reach the server through a proxy without authentication, but the 
result is that the remote server doesn't accept my connection.

This in my code:

   public static void main(String[] args) throws Exception
   {
       HttpClient client = new HttpClient();
       client.getParams().setAuthenticationPreemptive(true);
       client.getHostConfiguration().setProxy("proxyHost", 80);

       Credentials defaultcreds = new 
UsernamePasswordCredentials("login", "pwd");
       client.getState().setCredentials(new AuthScope("remotehost", 433, 
AuthScope.ANY_REALM), defaultcreds);

       GetMethod httpget = new GetMethod("https://remotehost/service");
       httpget.getParams().setCookiePolicy(CookiePolicy.RFC_2109);
       httpget.setDoAuthentication(true);

       try
       {
           client.executeMethod(httpget);
           System.out.println(httpget.getStatusLine());
       }
       finally
       {
           httpget.releaseConnection();
       }
   }

the result is

HTTP/1.1 401 Authorization Required.

I use:
commons-httpclient-3.1.jar
jdk1.6.0_06

Can someone help me?

Thank you.

---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org


Re: HttpClient SSL AUTHENTICATION PROBLEM

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Fri, 2008-09-05 at 10:02 +0200, Marco Geirola wrote:
> Hi,
> 
> I'm tring to connect to a server over HTTPS protocol but I cannot 
> authenticate the client.
> I can reach the server through a proxy without authentication, but the 
> result is that the remote server doesn't accept my connection.
> 
> This in my code:
> 
>    public static void main(String[] args) throws Exception
>    {
>        HttpClient client = new HttpClient();
>        client.getParams().setAuthenticationPreemptive(true);
>        client.getHostConfiguration().setProxy("proxyHost", 80);
> 
>        Credentials defaultcreds = new 
> UsernamePasswordCredentials("login", "pwd");
>        client.getState().setCredentials(new AuthScope("remotehost", 433, 
> AuthScope.ANY_REALM), defaultcreds);
> 
>        GetMethod httpget = new GetMethod("https://remotehost/service");
>        httpget.getParams().setCookiePolicy(CookiePolicy.RFC_2109);
>        httpget.setDoAuthentication(true);
> 
>        try
>        {
>            client.executeMethod(httpget);
>            System.out.println(httpget.getStatusLine());
>        }
>        finally
>        {
>            httpget.releaseConnection();
>        }
>    }
> 
> the result is
> 
> HTTP/1.1 401 Authorization Required.
> 
> I use:
> commons-httpclient-3.1.jar
> jdk1.6.0_06
> 
> Can someone help me?
> 

Please post a complete wire / context log of the session. 

http://hc.apache.org/httpclient-3.x/logging.html

Oleg


> Thank you.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org