title: Unable to feed certificate and key into openssl via stdin
body: <p>I have followed the <a href="https://stackoverflow.com/questions/16480846/x-509-private-public-key">steps listed here</a> to create a new private key and certificate. Now I am trying to combine them into a .pfx file.</p>
  
  <p>OpenSSL should be able to read in both the private key and the certificate from a single file, and according the man <code>man</code> docs, should also be able to read from <code>stdin</code>. However, this doesn't seem to be working for me.</p>
  
  <p>On Mac OS X 10.14.3 and <code>openssl version</code> gives "LibreSSL 2.6.5".</p>
  
  <p>I combined my certificate and key into one file (called 'combined.pem'). I did this with the following commands:</p>
  
  <pre><code>$ openssl genrsa -out private.key 2048
  $ openssl req -new -x509 -key private.key -out public.cer -days 365
  $ cat public.cer &gt;&gt; combined.pem
  $ cat private.key &gt;&gt; combined.pem
  </code></pre>
  
  <p>For reference, <code>combined.pem</code> looks something like this:</p>
  
  <pre><code>-----BEGIN CERTIFICATE-----
  ...
  -----END CERTIFICATE-----
  -----BEGIN RSA PRIVATE KEY-----
  ...
  -----END RSA PRIVATE KEY-----
  </code></pre>
  
  <p>When I run the following command, everything works fine:</p>
  
  <pre><code>$ openssl pkcs12 -export -out x509.pfx -in combined.pem
  </code></pre>
  
  <p>When I run this command, I get an error:</p>
  
  <pre><code>$ openssl pkcs12 -export -out x509.pfx &lt; combined.pem
  unable to load certificates
  </code></pre>
  
  <p>I have also tried:</p>
  
  <pre><code>$ cat combined.pem | openssl pkcs12 -export -out x509.pfx
  unable to load certificates
  </code></pre>
  
  <p>What am I missing? Is OpenSSL not really able to read from <code>stdin</code> for this?</p>
  
  <p>Also, from the <code>man</code> docs:</p>
  
  <pre><code>     -in file
             The input file to read from, or standard input if not specified.  The order doesn't matter but one private key and its corresponding certificate should
             be present.  If additional certificates are present, they will also be included in the PKCS#12 file.
  
       -inkey file
             File to read a private key from.  If not present, a private key must be present in the input file.
  </code></pre>