title: How can I open a *.cer file with FileInputStream --Android
body: <p>At this moment I'm trying to add some certificates to Keystore,because I need that Okthpp accepts this certs.</p>
  
  <p>So, Looking in developer android I saw this example: <a href="https://developer.android.com/training/articles/security-ssl.html?hl=es#HttpsExample" rel="nofollow noreferrer">https://developer.android.com/training/articles/security-ssl.html?hl=es#HttpsExample</a></p>
  
  <p>IN the example they do this:</p>
  
  <pre><code>// Load CAs from an InputStream
  // (could be from a resource or ByteArrayInputStream or ...)
  CertificateFactory cf = CertificateFactory.getInstance("X.509");
  // From https://www.washington.edu/itconnect/security/ca/load-der.crt
  InputStream caInput = new BufferedInputStream(new FileInputStream("load-der.crt"));
  Certificate ca;
  </code></pre>
  
  <p>What I've done, is try to load the cert from <code>.../res/raw/xxxxx*cer</code>file I added into project structure.</p>
  
  <p>So my code looks like:</p>
  
  <pre><code>CertificateFactory cf = CertificateFactory.getInstance("X.509");
  caInput1 = new BufferedInputStream(new FileInputStream(String.valueOf(ctx.getResources().openRawResourceFd(R.raw.xxxx))));
  </code></pre>
  
  <p>But when I try it, doesnt work:</p>
  
  <p><a href="https://i.stack.imgur.com/iZTE6.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/iZTE6.png" alt="enter image description here"></a></p>
  
  <p>How can I solve it? OR is not possible ?</p>