wood burning stoves
The moose likes Sockets and Internet Protocols and the fly likes JSSE Problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "JSSE Problem" Watch "JSSE Problem" New topic

JSSE Problem

Ahilan Ponnusamy

Joined: Aug 07, 2005
Posts: 1
I am trying to implement https download from our partners site.I got the .PFX(PKCS12) file from the client site & installed it in IE . I was able to connect to the site and download the file. But when I use the same file as keystore for my java client and try to connect to the site , I get a
javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: No trusted certificate found
exception .

I learned that this is due to the unavailability of TrustStore ..So I created a certificate file (.cer) file from the .pfx file and added that to the trust store ..But that also didnt help.

I have added my code below

import java.security.*;
import java.io.*;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.*;
import javax.net.ssl.SSLSocketFactory;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.KeyManager;
import javax.net.ssl.KeyManagerFactory;
import javax.net.ssl.KeyManagerFactorySpi;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSession;

public class KeyTest {
public static void main(String[] args) throws Exception {

javax.net.ssl.SSLContext ctx;
javax.net.ssl.KeyManagerFactory kmf;
javax.net.ssl.TrustManagerFactory tmf;
java.security.KeyStore ks,ks1;

ctx = javax.net.ssl.SSLContext.getInstance("SSL");
kmf = javax.net.ssl.KeyManagerFactory.getInstance("SunX509");
tmf = javax.net.ssl.TrustManagerFactory.getInstance("SunX509");
ks1 = java.security.KeyStore.getInstance("JKS");

ks = java.security.KeyStore.getInstance("JKS");

ks.load(new java.io.FileInputStream("AccessMed_Certificate1.pfx"), "cel_auto".toCharArray());

ks1.load(new java.io.FileInputStream("accessmedcatrust"), "cel_auto".toCharArray());
catch(java.io.IOException ex)

kmf.init(ks, "cel_auto".toCharArray());

System.out.println("Trust manager set :");


java.net.URL myUrl = new java.net.URL("https://clientsite.com");
javax.net.ssl.HttpsURLConnection conn = (javax.net.ssl.HttpsURLConnection) myUrl.openConnection();
System.out.println("after context factory::::::::::::::::");

java.io.InputStream in = conn.getInputStream();


Expecting some solution for this problem
warm regards
I agree. Here's the link: http://aspose.com/file-tools
subject: JSSE Problem
It's not a secret anymore!