Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Connecting to HTTPS - unable to find valid certification path to reque

Status
Not open for further replies.

jamojo

IS-IT--Management
Jun 12, 2008
4
0
0
PH
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 ( 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 {
HttpsConnection.ConnectToSSL(HttpsAddress,FileDestination,0);
} catch (Exception e) {
// TODO Auto-generated catch block
System.out.println("HttpsConnection Exception: " + e.getMessage());
e.printStackTrace();
}
}

public static void ConnectToSSL(String HttpsAddress,String FileDestination,int upload) throws Exception {

// Dynamic registration of JSSE provider
java.security.Security.addProvider(
new com.sun.net.ssl.internal.ssl.Provider());

// Need to be set
System.setProperty(
"java.protocol.handler.pkgs",
"com.sun.net.ssl.internal.
// Install Authenticator
Authenticator.setDefault (new PasswordAuthenticator());

URL url = new URL(HttpsAddress);

BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));

String InputLine;

if (upload==1){
UploadDataFile.FileUpload(HttpsAddress,FileDestination);
}else{
int i = 0;
while ((InputLine = in.readLine()) != null){
if (i==7){
HttpsScanFlatFile.ScanHttpsFile(InputLine,HttpsAddress,FileDestination);
}
i++;
}
in.close();
}
}
}

class PasswordAuthenticator extends Authenticator {
public void ExperianCreditAuthenticator() {
}

protected PasswordAuthentication getPasswordAuthentication() {
System.out.println("Connecting to HTTPS Site...");
return new PasswordAuthentication("Username","Password".toCharArray());
}
}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 {
HttpsConnection.ConnectToSSL(HttpsAddress,FileDestination,0);
} catch (Exception e) {
// TODO Auto-generated catch block
System.out.println("HttpsConnection Exception: " + e.getMessage());
e.printStackTrace();
}
}

public static void ConnectToSSL(String HttpsAddress,String FileDestination,int upload) throws Exception {

// Dynamic registration of JSSE provider
java.security.Security.addProvider(
new com.sun.net.ssl.internal.ssl.Provider());

// Need to be set
System.setProperty(
"java.protocol.handler.pkgs",
"com.sun.net.ssl.internal.
// Install Authenticator
Authenticator.setDefault (new PasswordAuthenticator());

URL url = new URL(HttpsAddress);

BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));

String InputLine;

if (upload==1){
UploadDataFile.FileUpload(HttpsAddress,FileDestination);
}else{
int i = 0;
while ((InputLine = in.readLine()) != null){
if (i==7){
HttpsScanFlatFile.ScanHttpsFile(InputLine,HttpsAddress,FileDestination);
}
i++;
}
in.close();
}
}
}

class PasswordAuthenticator extends Authenticator {
public void ExperianCreditAuthenticator() {
}

protected PasswordAuthentication getPasswordAuthentication() {
System.out.println("Connecting to HTTPS Site...");
return new PasswordAuthentication("Username","Password".toCharArray());
}
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top