When trying to connect to our own secure server using this code we get a
SSLException saying that the cert chain is untrusted.
The certificate in the server has been generated by verisign as a trial
cert.
We can't see the cipherSuite nor the certificate chain. The exception
must be thrown in connection time.

Is there any configuration stuff we haven't consider ??
Is there a problem in the client code ??

        try{
            System.setProperty("java.protocol.handler.pkgs",
"com.sun.net.ssl.internal.www.protocol");
            Security.addProvider(new
com.sun.net.ssl.internal.ssl.Provider());
            URL urls = new URL("https://our.own.server");
            URLConnection con = urls.openConnection();
            con.setAllowUserInteraction(true);
            HttpsURLConnection cons = (HttpsURLConnection) con;
            if (cons == null)
                System.out.println("La conexión el nula!!!");
            System.out.println("Cypher Suite:" + cons.getCipherSuite());

            cons.connect();
            X509Certificate[] serverCerts =
cons.getServerCertificateChain();
            System.out.println("Certificados:" + serverCerts.length);
            for (int i = 0; i < serverCerts.length; i++) {
                System.out.println(serverCerts[i].toString());
            }

            System.out.println("Headers:" + con.getHeaderFieldKey(0));
            BufferedReader reader = new BufferedReader(new
InputStreamReader(con.getInputStream()));
            String line = reader.readLine();
            while (line != null) {
                System.out.println(line);
                line = reader.readLine();
            }
        } catch (SSLException e) {
            System.out.println("Excepción SSL: " + e.toString());
        } catch (Exception e){
            e.printStackTrace();
        }



Reply via email to