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 arpita k <ar...@gmail.com> on 2010/07/21 18:04:42 UTC

How to upgrade httpclient 3.0 to httpclient 4.0?

Hi,

I am using common-httpclient 3.0 and common-ssl 0.3.11 library to establish
SSL communication between client and the server.Here is the code:


*AuthSSLProtocolSocketFactory myAuthFactory = null;
        try
        {
            myAuthFactory = new AuthSSLProtocolSocketFactory(new URL("file:"
                    + KEYSTORE_LOCATION), KEYSTORE_PASSWORD, new URL("file:"
                    + TRUSTSTORE_LOCATION), TRUSTSTORE_PASSWORD);


            Protocol myhttps = new Protocol("https", myAuthFactory,
serverPort);
            Protocol.registerProtocol("https", myhttps);
            signClient.getHostConfiguration().setHost(serverName,
serverPort,
                    myhttps);
            signClient.getParams().setCookiePolicy(CookiePolicy.RFC_2109);

*
The AuthSSLProtocolSocketFactory  is part of common-ssl library.
Now I need to upgrade the httpclient from 3.0 to 4.0.But I want to use the
AuthSSLProtocolSocketFactory  factory as it is doin gCRL check
automatically.

I know that the schem is replaced by the Protocol of httpclient 4.0.But I
don't think it could take AuthSSLProtocolSocketFactory   as a parameter.So,
which way I should proceed?

Please help me to upgrade the httpclient.

Thanks in advance!!

Arpita

Re: How to upgrade httpclient 3.0 to httpclient 4.0?

Posted by arpita k <ar...@gmail.com>.
Hi Oleg,

Thanks for your reply.
But I am using the the *CRL check* feature of the not-yet-common-ssl library
and that's why I am using the *AuthSSLProtocolSocketFactory *factory.Is the
class *AuthSSLProtocolSocketFactory* compatible with* *the *Httpclient
4.0*library
*?*

~Arpita

On Thu, Jul 22, 2010 at 1:01 AM, Oleg Kalnichevski <ol...@apache.org> wrote:

> On Wed, 2010-07-21 at 21:34 +0530, arpita k wrote:
> > Hi,
> >
> > I am using common-httpclient 3.0 and common-ssl 0.3.11 library to
> establish
> > SSL communication between client and the server.Here is the code:
> >
> >
> > *AuthSSLProtocolSocketFactory myAuthFactory = null;
> >         try
> >         {
> >             myAuthFactory = new AuthSSLProtocolSocketFactory(new
> URL("file:"
> >                     + KEYSTORE_LOCATION), KEYSTORE_PASSWORD, new
> URL("file:"
> >                     + TRUSTSTORE_LOCATION), TRUSTSTORE_PASSWORD);
> >
> >
> >             Protocol myhttps = new Protocol("https", myAuthFactory,
> > serverPort);
> >             Protocol.registerProtocol("https", myhttps);
> >             signClient.getHostConfiguration().setHost(serverName,
> > serverPort,
> >                     myhttps);
> >
> signClient.getParams().setCookiePolicy(CookiePolicy.RFC_2109);
> >
> > *
> > The AuthSSLProtocolSocketFactory  is part of common-ssl library.
> > Now I need to upgrade the httpclient from 3.0 to 4.0.But I want to use
> the
> > AuthSSLProtocolSocketFactory  factory as it is doin gCRL check
> > automatically.
> >
> > I know that the schem is replaced by the Protocol of httpclient 4.0.But I
> > don't think it could take AuthSSLProtocolSocketFactory   as a
> parameter.So,
> > which way I should proceed?
> >
>
> You should create an instance of SSLContext using not-yet-commons SSL
> and pass it to the constructor of the SSLSocketFactory as described
> here:
>
>
> http://hc.apache.org/httpcomponents-client-4.0.1/tutorial/html/connmgmt.html#d4e497
>
> Oleg
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>
>

Re: How to upgrade httpclient 3.0 to httpclient 4.0?

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Wed, 2010-07-21 at 21:34 +0530, arpita k wrote:
> Hi,
> 
> I am using common-httpclient 3.0 and common-ssl 0.3.11 library to establish
> SSL communication between client and the server.Here is the code:
> 
> 
> *AuthSSLProtocolSocketFactory myAuthFactory = null;
>         try
>         {
>             myAuthFactory = new AuthSSLProtocolSocketFactory(new URL("file:"
>                     + KEYSTORE_LOCATION), KEYSTORE_PASSWORD, new URL("file:"
>                     + TRUSTSTORE_LOCATION), TRUSTSTORE_PASSWORD);
> 
> 
>             Protocol myhttps = new Protocol("https", myAuthFactory,
> serverPort);
>             Protocol.registerProtocol("https", myhttps);
>             signClient.getHostConfiguration().setHost(serverName,
> serverPort,
>                     myhttps);
>             signClient.getParams().setCookiePolicy(CookiePolicy.RFC_2109);
> 
> *
> The AuthSSLProtocolSocketFactory  is part of common-ssl library.
> Now I need to upgrade the httpclient from 3.0 to 4.0.But I want to use the
> AuthSSLProtocolSocketFactory  factory as it is doin gCRL check
> automatically.
> 
> I know that the schem is replaced by the Protocol of httpclient 4.0.But I
> don't think it could take AuthSSLProtocolSocketFactory   as a parameter.So,
> which way I should proceed?
> 

You should create an instance of SSLContext using not-yet-commons SSL
and pass it to the constructor of the SSLSocketFactory as described
here:

http://hc.apache.org/httpcomponents-client-4.0.1/tutorial/html/connmgmt.html#d4e497  

Oleg


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


Re: How to upgrade httpclient 3.0 to httpclient 4.0?

Posted by Ryan Smith <ry...@gmail.com>.
Id like to add on, is there an overall guide to upgrade from 3.x to 4.x?

Thanks,
-Ryan

On Wed, Jul 21, 2010 at 12:04 PM, arpita k <ar...@gmail.com> wrote:

> Hi,
>
> I am using common-httpclient 3.0 and common-ssl 0.3.11 library to establish
> SSL communication between client and the server.Here is the code:
>
>
> *AuthSSLProtocolSocketFactory myAuthFactory = null;
>        try
>        {
>            myAuthFactory = new AuthSSLProtocolSocketFactory(new URL("file:"
>                    + KEYSTORE_LOCATION), KEYSTORE_PASSWORD, new URL("file:"
>                    + TRUSTSTORE_LOCATION), TRUSTSTORE_PASSWORD);
>
>
>            Protocol myhttps = new Protocol("https", myAuthFactory,
> serverPort);
>            Protocol.registerProtocol("https", myhttps);
>            signClient.getHostConfiguration().setHost(serverName,
> serverPort,
>                    myhttps);
>            signClient.getParams().setCookiePolicy(CookiePolicy.RFC_2109);
>
> *
> The AuthSSLProtocolSocketFactory  is part of common-ssl library.
> Now I need to upgrade the httpclient from 3.0 to 4.0.But I want to use the
> AuthSSLProtocolSocketFactory  factory as it is doin gCRL check
> automatically.
>
> I know that the schem is replaced by the Protocol of httpclient 4.0.But I
> don't think it could take AuthSSLProtocolSocketFactory   as a parameter.So,
> which way I should proceed?
>
> Please help me to upgrade the httpclient.
>
> Thanks in advance!!
>
> Arpita
>