title: Eclipse unable to find valid certification path to requested target
body: <p>I am attempting to send an email via smtp to smtp.mailgun.org. I am not concerned about the java code that is attempting to send the email.</p>
  
  <p><strong>Environment:</strong>  </p>
  
  <blockquote>
    <p>Windows 10   Eclipse Photon  Java 1.8.0_191  java package:
    com.sun.mail.javax.mail:1.6.2</p>
  </blockquote>
  
  <p>I am trying to send through 587 using TLS. I don't have much experience creating or modifying keystores. </p>
  
  <p>In the <code>eclipse.ini</code>, I added the following two arguments after the -vmargs</p>
  
  <pre><code>-Djavax.net.ssl.trustStore="C:/Program Files/Java/jdk1.8.0_192/jre/lib/security/cacerts "
  
  -Djavax.net.ssl.trustStorePassword="password"
  </code></pre>
  
  <p>I restarted Eclipse and am continuing to get the error below.</p>
  
  <pre><code>javax.mail.MessagingException: Could not convert socket to TLS;
        nested exception is:
          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 com.sun.mail.smtp.SMTPTransport.startTLS(SMTPTransport.java:1652)
          at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:534)
          at javax.mail.Service.connect(Service.java:291)
          at javax.mail.Service.connect(Service.java:172)
          at com.mako.mg.manager.MakoMailGunSmtpManager.sendEmail(MakoMailGunSmtpManager.java:158)
          at com.mako.mg.manager.MakoMailGunSmtpManager.main(MakoMailGunSmtpManager.java:180)
      Caused by: 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(Unknown Source)
          at sun.security.ssl.SSLSocketImpl.fatal(Unknown Source)
          at sun.security.ssl.Handshaker.fatalSE(Unknown Source)
          at sun.security.ssl.Handshaker.fatalSE(Unknown Source)
          at sun.security.ssl.ClientHandshaker.serverCertificate(Unknown Source)
          at sun.security.ssl.ClientHandshaker.processMessage(Unknown Source)
          at sun.security.ssl.Handshaker.processLoop(Unknown Source)
          at sun.security.ssl.Handshaker.process_record(Unknown Source)
          at sun.security.ssl.SSLSocketImpl.readRecord(Unknown Source)
          at sun.security.ssl.SSLSocketImpl.performInitialHandshake(Unknown Source)
          at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)
          at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)
          at com.sun.mail.util.SocketFetcher.configureSSLSocket(SocketFetcher.java:503)
          at com.sun.mail.util.SocketFetcher.startTLS(SocketFetcher.java:443)
          at com.sun.mail.smtp.SMTPTransport.startTLS(SMTPTransport.java:1647)
          ... 5 more
      Caused by: 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.validator.PKIXValidator.doBuild(Unknown Source)
          at sun.security.validator.PKIXValidator.engineValidate(Unknown Source)
          at sun.security.validator.Validator.validate(Unknown Source)
          at sun.security.ssl.X509TrustManagerImpl.validate(Unknown Source)
          at sun.security.ssl.X509TrustManagerImpl.checkTrusted(Unknown Source)
          at sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(Unknown Source)
          ... 16 more
      Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
          at sun.security.provider.certpath.SunCertPathBuilder.build(Unknown Source)
          at sun.security.provider.certpath.SunCertPathBuilder.engineBuild(Unknown Source)
          at java.security.cert.CertPathBuilder.build(Unknown Source)
          ... 22 more
  </code></pre>
  
  <p>Is my Eclipse having a problem using the cacerts? or do I need to create a keystore from the cacerts?</p>
  
  <p>I cannot find <code>c:\users\&lt;myuser&gt;\.keystore</code>. I am configured to view hidden files and folders.</p>
  
  <p>Thank you for your help with this issue.</p>