title: Unable to find valid certification path to requested target, trying to use a SMS api via https request
body: <p>I'm trying to send a SMS from java using an API.</p>
  <p>I just need to make an https request with parameters written in the URL.</p>
  <p><a href="https://notificame.claro.com.hn/api/http/send_to_contact?msisdn504999999=&amp;message=mymessage&amp;api_key=00000&amp;id=000" rel="nofollow noreferrer">https://notificame.claro.com.hn/api/http/send_to_contact?msisdn504999999=&amp;message=mymessage&amp;api_key=00000&amp;id=000</a></p>
  <p>If I copy the resulting url and paste it directly on my browser, it sends the SMS.</p>
  <p>I have a working code using this on PHP, but I need it working on JAVA</p>
  <p>I've tried this:</p>
  <pre><code>try 
      {
          HttpsURLConnection con;
          URL url = new URL(pre_url); 
          con = (HttpsURLConnection) url.openConnection();
          System.out.println(url.getContent());
  
      } catch (MalformedURLException ex) {
          Logger.getLogger(crearUsuarioBean.class.getName()).log(Level.SEVERE, null, ex);
      } catch (IOException ex) {
          Logger.getLogger(crearUsuarioBean.class.getName()).log(Level.SEVERE, null, ex);
      }
  </code></pre>
  <p>but Im getting this error:</p>
  <pre><code>Severe:   javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
  at sun.security.ssl.Alerts.getSSLException(Alerts.java:192)
  at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1949)
  at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:302)...
  </code></pre>
  <p>I also followed some instructions using keytool to add the certificate with .cer to cacerts but had no success. I have two folders, jdk1.8.0_131 and jre1.8.0_131, so I tried installing the certificate on both already. Still no success.</p>
  <p>This is the code that makes the job for me on PHP:</p>
  <pre><code>function enviarMensaje($cel, $solicitud, $id){     
  $mensaje=&quot;My message&quot;;
  $url = &quot;https://notificame.claro.com.hn/api/http/send_to_contact?msisdn=504&quot;.$cel.&quot;&amp;message=&quot;.$mensaje.&quot;&amp;api_key=MyAppiKey&amp;id=&quot;.$id;
  $url = str_replace(&quot; &quot;, &quot;%20&quot;, $url);
  file($url);
  echo $url.&quot;&lt;br /&gt;\n&quot;;   
  </code></pre>
  <p>}</p>
  <p>I just need something simple like this.
  Im working on JSF2.2 using Primefaces</p>
  <p>Or maybe some way to call a simple php code directly from java.</p>
  <p>Help please.</p>