Riad,

Does your postmethod target a relative URL, and not an absolute one? If
it does not, make sure it does

sslProtocol = new Protocol("https", factory, "443");
HostConfiguration hostConf = new HostConfiguration();
hostConf.setHost("localhost", 443, sslProtocol)

// Will pick up sslProtocol from hostConf
PostMethod postmethod = new PostMethod("/relative");
client.executeMethod(hostConf, postmethod)

// Will ALWAYS pick up the default Protocol (the one registered using 
// Protocol#registerProtocol
// hostConf will have no effect because the host and protocol are 
// given in the URL itself
PostMethod postmethod = new PostMethod("https://localhost/absolute";);
client.executeMethod(hostConf, postmethod);

Oleg

On Fri, 2005-07-22 at 11:33 -0700, Riad Souissi wrote:
> Hi again,
> 
> I forgot to mention something:
> 
> I am not using :
> - client.getHostConfiguration().setHost("localhost", 443, sslProtocol)
> I use instead: 
> - hostConf.setHost("localhost", 443, sslProtocol)
> - client.executeMethod(hostConf, postmethod)
> 
> But it is the same, it gives the same problem
> 
> riad
> 
> 
> --- Riad Souissi <[EMAIL PROTECTED]> wrote:
> 
> > 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: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> > 
> > 
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around 
> http://mail.yahoo.com 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 


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

Reply via email to