Hello everyone,

I am using the code below. It is working when I used this in Eclipse. What I did is to place the generated keystore from the InstallCert.class (http://blogs.sun.com/andreas/resource/InstallCert.java) to the latest JRE in the Program Files>Java

But when I deployed this class in the Tomcat/Bea its searching I am receiving this errors:

BEA Weblogic - HttpsConnection Exception: [Security:090477]Certificate chain received from <site> - <ip> was not trusted causing SSL handshake failure.

TOMCAT: HttpsConnection Exception: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target.

Can you give me an idea on how to resolve this issue? Your replies are greatly appreciated.

Looking forward to your replies.

Thanks in Advance

import java.io.*;
import java.net.Authenticator;
import java.net.PasswordAuthentication;
import java.net.URL;

public class HttpsConnection {
	public static void ConnectToHttps(String HttpsAddress,String FileDestination,int upload){
		try {
		} catch (Exception e) {
			// TODO Auto-generated catch block
			System.out.println("HttpsConnection Exception: " + e.getMessage());
    public static void ConnectToSSL(String HttpsAddress,String FileDestination,int upload) throws Exception {
		// Dynamic registration of JSSE provider
	          new com.sun.net.ssl.internal.ssl.Provider());
	    // Need to be set
	    // Install Authenticator
	    Authenticator.setDefault (new PasswordAuthenticator());
		URL url = new URL(HttpsAddress);
		BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
		String InputLine;
		if (upload==1){
			int i = 0;
			while ((InputLine = in.readLine()) != null){
			    if (i==7){

	class PasswordAuthenticator extends Authenticator {
		public void ExperianCreditAuthenticator() {

		protected PasswordAuthentication getPasswordAuthentication() {
    	System.out.println("Connecting to HTTPS Site...");
    	return new PasswordAuthentication("Username","Password".toCharArray());

Any suggestions or ideas please?

i get the same problem! you need install the certificate in your jdk./
such as , i use the keytool utility to generate the *.cer file and import it
to my jdk.but i still get the mistake ,still work hard!