0
votes

the error is : sun.security.validator.ValidatorException: PKIX path validation failed: java.security.cert.CertPathValidatorException: timestamp check failed

the code used is :

create or replace and compile java source named sendsms as
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import javax.net.ssl.HttpsURLConnection;
public class HttpsCall {
public static void main(String[] args) throws Exception {
        
String httpsURL = "https://www.jawalbsms.ws/api.php/sendsms?user=abc&pass=xyz&to=9665555555555&message=good morning&sender=abc";
        
 URL myUrl = new URL(httpsURL);
 HttpsURLConnection conn = (HttpsURLConnection) myUrl.openConnection();
 InputStream is = conn.getInputStream();
 InputStreamReader isr = new InputStreamReader(is);
 BufferedReader br = new BufferedReader(isr);

 String inputLine;

 while ((inputLine = br.readLine()) != null) {
       System.out.println(inputLine);
        }

    br.close();

} }

1

1 Answers

0
votes

solved by adding following lines to the code ,now working from oracle 12c fine

 SSLContext context = SSLContext.getInstance("TLSv1.2");
 TrustManager[] trustManager = new TrustManager[] {
 new X509TrustManager() {
 public X509Certificate[] getAcceptedIssuers() {
        return new X509Certificate[0];
      }
 public void checkClientTrusted(X509Certificate[] certificate, String str) {}
             public void checkServerTrusted(X509Certificate[] certificate, String      str) {}
    }
  };
context.init(null, trustManager, new SecureRandom());


HttpsURLConnection.setDefaultSSLSocketFactory(context.getSocketFactory());

javax.net.ssl.HttpsURLConnection.setDefaultHostnameVerifier(
new HostnameVerifier(){
public boolean verify(String hostname, SSLSession session) {   
       return true;   
  }
    });