hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Carlos Cort├ęs del Valle de la Lastra <ccor...@redauto.com>
Subject Problem with SSL Certificate
Date Wed, 19 Feb 2003 17:37:11 GMT
I have a problem using httpclient classes. I need connect through https protocol with PostMethod.
But, when I execute the method, an Exception ocurred because it doesn't find the certificate
i've created for this

public class RobotImpl{

    //Init server...    
    public void iniciar() throws ExceptionGlobal{
                URL u = new URL("https://localhost:8443/Jsp2.jsp");
                org.apache.commons.httpclient.URI uri=new org.apache.commons.httpclient.URI(u);
                HttpClient client = new HttpClient();
                HostConfiguration hc = new HostConfiguration();

                PostMethod post = new PostMethod("https://localhost:8443/Jsp2.jsp");

                int iResultCode = client.executeMethod(post);
}//end code

Exception Message

javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException: Couldn't find
trusted certificate
 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)...........

I tried to create a trust manager that does not validate certificate chains, but it doesn't
works... this is the code

TrustManager[] trustAllCerts = new TrustManager[]{
    new X509TrustManager() {
    public java.security.cert.X509Certificate[] getAcceptedIssuers() {
        return null;
    public void checkClientTrusted(
            java.security.cert.X509Certificate[] certs, String authType) {
    public void checkServerTrusted(
            java.security.cert.X509Certificate[] certs, String authType) {
// Install the all-trusting trust manager
try {
    SSLContext sc = SSLContext.getInstance("SSL");
    sc.init(null, trustAllCerts, new java.security.SecureRandom());
} catch (Exception e) {

thanks for advance,
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message