hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Riad Souissi <riadsoui...@yahoo.com>
Subject Problem with V3 RC3 and HTTPClient.getHostConfiguration().setHost("localhost", "443", sslProtocol) not working anymore
Date Fri, 22 Jul 2005 17:35:24 GMT
Hi,

I had the following code which used to work from Beta1 to RC2 but stopped to work in RC3:

HTTPClient client = ...
SecureProtocolSocketFactory factory = ...
sslProtocol = new Protocol("https", factory, "443");
client.getHostConfiguration().setHost("localhost", "443", sslProtocol);

After I moved to RC3, I always have this java error:

avax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: No trusted
certificate found
       at com.sun.net.ssl.internal.ssl.BaseSSLSocketImpl.a(DashoA6275)
       at com.sun.net.ssl.internal.ssl.SSLSocketImpl.a(DashoA6275)
       at com.sun.net.ssl.internal.ssl.SSLSocketImpl.a(DashoA6275)
       at com.sun.net.ssl.internal.ssl.SunJSSE_az.a(DashoA6275)
       at com.sun.net.ssl.internal.ssl.SunJSSE_az.a(DashoA6275)
       at com.sun.net.ssl.internal.ssl.SunJSSE_ax.a(DashoA6275)
       at com.sun.net.ssl.internal.ssl.SSLSocketImpl.a(DashoA6275)
       at com.sun.net.ssl.internal.ssl.SSLSocketImpl.j(DashoA6275)
       at com.sun.net.ssl.internal.ssl.SSLSocketImpl.a(DashoA6275)
       at com.sun.net.ssl.internal.ssl.AppOutputStream.write(DashoA6275)
       at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:66)
       at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:124)
       at
org.apache.commons.httpclient.methods.StringRequestEntity.writeRequest(StringRequestEntity.java:140)
       at
org.apache.commons.httpclient.methods.EntityEnclosingMethod.writeRequestBody(EntityEnclosingMethod.java:495)
       at org.apache.commons.httpclient.HttpMethodBase.writeRequest(HttpMethodBase.java:1973)
       at org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:993)
       at
org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:393)
       at
org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:168)
       at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:396)
       at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:346)

As if it does not use the custom SecureProtocolSocketFactory anymore (and from the traces
in my
custom SecureProtocolSocketFactory, it never gets called)
Then for testing, I changed the last line of the code to: Protocol.registerProtocol("https",
sslProtocol)

It still did not work, but for a different reason which I could not explain:

javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException: Untrusted Server
Certificate Chain
        at com.sun.net.ssl.internal.ssl.BaseSSLSocketImpl.a(DashoA6275)
        at com.sun.net.ssl.internal.ssl.SSLSocketImpl.a(DashoA6275)
        at com.sun.net.ssl.internal.ssl.SSLSocketImpl.a(DashoA6275)
        at com.sun.net.ssl.internal.ssl.SunJSSE_az.a(DashoA6275)
        at com.sun.net.ssl.internal.ssl.SunJSSE_az.a(DashoA6275)
        at com.sun.net.ssl.internal.ssl.SunJSSE_ax.a(DashoA6275)
        at com.sun.net.ssl.internal.ssl.SSLSocketImpl.a(DashoA6275)
        at com.sun.net.ssl.internal.ssl.SSLSocketImpl.j(DashoA6275)
        at com.sun.net.ssl.internal.ssl.SSLSocketImpl.a(DashoA6275)
        at com.sun.net.ssl.internal.ssl.AppOutputStream.write(DashoA6275)
        at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:66)
        at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:124)
        at
org.apache.commons.httpclient.methods.StringRequestEntity.writeRequest(StringRequestEntity.java:140)
        at
org.apache.commons.httpclient.methods.EntityEnclosingMethod.writeRequestBody(EntityEnclosingMethod.java:495)
        at org.apache.commons.httpclient.HttpMethodBase.writeRequest(HttpMethodBase.java:1973)
        at org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:993)
        at
org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:393)
        at
org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:168)
        at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:396)
        at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:346)

My custom SSLProtocol gets invoked this time but for some reason, the method
defaultTrustManager.isServerTrusted(certificates) always returns false eventhough it is exactly
the same which gets invoked in RC2 with the HostConfiguration.
I can also see from my own logs that the same server certificates are sent to the HTTPClient
but
this time they are not recognized !

By the way, even if Protocol.registerProtocol(), I cannot use it because it overrides all
the SSL
protocols at the level of the port. but in my custom client, I have different HTTPClients
connecting to the same port but on different hosts.

Any idea ?

Thanks
riad

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

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


Mime
View raw message