On Tue, 2008-04-22 at 10:09 +0530, keith chapman wrote:
> Hi All,
> 
> I have a scenario where I want to use two separate keystores to talk to two
> different sites over https. There is a chance that these two client may
> execute in parallel. As I understand java lets you set keystore information
> using system properties. With the above scenario system properties will be a
> problem. Is there a mechanism that I can use the httpClient API to perform
> the above operation?
> 

Hi Keith,

Sure. Just create two instances of AuthProtocolSocketFactory from the
contrib package with different SSL contexts and create distinct
Protocol / HostConfiguration instances per socket factory. 


ProtocolSocketFactory sf1 = new SSLProtocolSocketFactory();
ProtocolSocketFactory sf2 = new SSLProtocolSocketFactory();
        
Protocol myhttps1 = new Protocol("https", sf1, 443);
Protocol myhttps2 = new Protocol("https", sf2, 443);
        
HostConfiguration hostconf1 = new HostConfiguration();
hostconf1.setHost("host1", 443, myhttps1);
        
HostConfiguration hostconf2 = new HostConfiguration();
hostconf1.setHost("host2", 443, myhttps2);

Please do not forget to use _relative_ request URIs when executing
requests with a custom HostConfiguration.

GetMethod httpget = new GetMethod("/stuff");
HttpState httpstate1 = new HttpState();
httpclient.executeMethod(hostconf1, httpget, httpstate1);

Hope this helps

Oleg


> Thanks,
> Keith.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to