Sorry.. half message... below is the completed code... this now works for
http requests with/without proxy...
thanks.
On 10/30/07, nitya vyas <[EMAIL PROTECTED]> wrote:
>
> Hi Julius,
>
> I think this Protocol.registerProtocol("https", stricthttps); will not
> work with httpClient 3.1 if i m not mistaken.. because open() method of
> HTTPConnection has this code...
>
> if (isSecure() && isProxied()) {
> Protocol defaultprotocol = Protocol.getProtocol("http");
> socketFactory = defaultprotocol.getSocketFactory();
> } else {
> socketFactory = this.protocolInUse.getSocketFactory();
> }
> Thers no code that gets the socketfactory from ID "https"...
>
> Anyways i found another solution for the problem .. i dont know if its
> proper... I removed the extends StrictSSL
>
>
> public class AsiteSocketFactory implements ProtocolSocketFactory {
>
> public AsiteSocketFactory(boolean isHttps) throws
> java.security.GeneralSecurityException, java.io.IOException{
>
> if(isHttps){
>
new StrictSSLProtocolSocketFactory(true);
}else{
> new DefaultProtocolSocketFactory();
> }
>
> public Socket createSocket(String host, int port) throws IOException,
> UnknownHostException {
> return new Socket(host,port);
> }
>
> public Socket createSocket(String host, int port, InetAddress
> localAddress, int localPort) throws IOException, UnknownHostException {
> return new Socket(host,port,localAddress,localPort);
> }
>
> public Socket createSocket(String host, int port, InetAddress
> localAddress, int localPort, HttpConnectionParams params)
> throws IOException, UnknownHostException, ConnectException {
> Socket rval;
> if (params == null) {
> throw new IllegalArgumentException("Parameters may not be
> null");
> }
> rval = new Socket(Proxy.NO_PROXY);
> SocketAddress localaddr = new
> InetSocketAddress(localAddress, localPort);
> SocketAddress remoteaddr = new InetSocketAddress(host, port);
> rval.bind(localaddr);
> rval.connect(remoteaddr);
> return rval;
> }
> }
>
>
> On 10/29/07, Julius Davies <[EMAIL PROTECTED]> wrote:
> >
> > I would recommend replacing this:
> > Protocol.registerProtocol("http", stricthttps);
> >
> >
> > With this:
> > Protocol.registerProtocol("https", stricthttps);
> >
> >
> > --
> > yours,
> >
> > Julius Davies
> > 250-592-2284 (Home)
> > 250-893-4579 (Mobile)
> > http://juliusdavies.ca/
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
>