title: Set certificate for KeyStore.TrustedCertificateEntry?
body: <p>I'm trying to skin this cat: <a href="https://stackoverflow.com/questions/22493997/use-pem-encode-ca-cert-on-filesystem-directly-for-https-request">Use PEM Encoded CA Cert on filesystem directly for HTTPS request?</a> another way.</p>
  
  <p>Java has a class <code>KeyStore.TrustedCertificateEntry</code>, but I can't figure out how to load a certificate into it. My code looks similar to below:</p>
  
  <pre><code>import java.security.KeyStore.TrustedCertificateEntry;
  ...
  
  X509Certificate ca = (X509Certificate) CertificateFactory(...);
  KeyStore ks = TrustedCertificateEntry(ca);
  </code></pre>
  
  <p>And:</p>
  
  <pre><code>X509Certificate ca = (X509Certificate) CertificateFactory(...);
  KeyStore ks = KeyStore.TrustedCertificateEntry(ca);
  </code></pre>
  
  <p>And:</p>
  
  <pre><code>X509Certificate ca = (X509Certificate) CertificateFactory(...);
  KeyStore ks = new KeyStore.TrustedCertificateEntry(ca);
  </code></pre>
  
  <p>And:</p>
  
  <pre><code>X509Certificate ca = (X509Certificate) CertificateFactory(...);
  KeyStore ks = new KeyStore.TrustedCertificateEntry(ca);
  </code></pre>
  
  <p>The program fails to compile with errors similar to:</p>
  
  <pre><code>SuperCert.java:33: error: cannot find symbol
  KeyStore ks = TrustedCertificateEntry(ca);
                  ^
    symbol:   method TrustedCertificateEntry(X509Certificate)
    location: class TestCert
  </code></pre>
  
  <p>After loading my X509 cert into the <code>KeyStore</code>, I plan on using it in a <code>TrustManagerFactory</code> and ultimately fetching a web page with <code>HttpsURLConnection</code>.</p>
  
  <p>How does one load a <code>X509Certificate</code> into a <code>TrustedCertificateEntry</code>?</p>