• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Could not find trusted certificate

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I run an java application to validate address in www.desertsoft.com.
But it throws following exceptions:
javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException: Could not 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)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.a(DashoA6275)IO Exception
Because www.desertsoft.com use SSL connection....
What can I do to solve the problem? Is there any stuff or example?
Next code is example code from www.desertsoft.com:
import java.net.*;
import java.io.*;
import java.security.Security;
import java.security.Provider;
import org.w3c.dom.*;
import javax.xml.parsers.*;
public class AddressValidator {
private static final String baseUrl =
"https://sws.desertsoft.com/AddVal/AddVal.asmx/AddVal?";
// values to validate
private static String addressLine = "1600 Pennsylvania Avenue";
private static String city = "Washington";
private static String state = "DC";
private static String zip = "20500";
private static String username = "desertsoft";
private static String password = "desertsoft";
private static String version = "1.1";
public static void main(String args[]) {
String requestUrl, nodeName, nodeValue; ;
try {
System.setProperty("java.protocol.handler.pkgs",
"com.sun.net.ssl.internal.www.protocol");
Class clsFactory = Class.forName(
"com.sun.net.ssl.internal.ssl.Provider");
if ( (null != clsFactory) &&
(null == Security.getProvider("SunJSSE"))) {
Security.addProvider( (Provider) clsFactory.newInstance());
}
// build request url
requestUrl = baseUrl + "strAdd1=" + URLEncoder.encode(addressLine);
requestUrl = requestUrl + "&strCity=" + URLEncoder.encode(city);
requestUrl = requestUrl + "&strState=" + URLEncoder.encode(state);
requestUrl = requestUrl + "&strZip=" + URLEncoder.encode(zip);
requestUrl = requestUrl + "&strUser=" + URLEncoder.encode(username);
requestUrl = requestUrl + "&strPass=" + URLEncoder.encode(password);
requestUrl = requestUrl + "&strVersion=" +
URLEncoder.encode(version);
System.out.println(requestUrl);
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setNamespaceAware(true);
dbf.setIgnoringComments(true);
DocumentBuilder db = dbf.newDocumentBuilder();
Document doc = db.parse(requestUrl);
// parse returned XML
Node n;
Node addressNode = doc.getFirstChild();
NodeList nodes = addressNode.getChildNodes();
for (int i = 0; i < nodes.getLength(); i++) {
n = nodes.item(i);
if (n.getNodeType() == Node.ELEMENT_NODE) {
nodeName = n.getNodeName();
nodeValue = n.getFirstChild().getNodeValue();
System.out.println(nodeName + ": " + nodeValue);
}
}
}
catch (IOException ioe) {
System.out.println("IO Exception");
ioe.printStackTrace();
}
catch (ClassNotFoundException cfe) {
System.out.println("Unable to load the JSSE SSL stream handler.");
}
catch (InstantiationException ie) {
System.out.println("InstantiationException occured.");
}
catch (IllegalAccessException iae) {
System.out.println("IllegalAccessException occured.");
}
catch (org.xml.sax.SAXException saxe) {
System.out.println("org.xml.sax.SAXException occured.");
}
catch (ParserConfigurationException pce) {
System.out.println("ParserConfigurationException occured.");
}
}
}
Please help
 
reply
    Bookmark Topic Watch Topic
  • New Topic