title: Converting pem with multiple certificates to java keystore
body: <p>I have been given a pem file which has two certificates in it. </p>
  
  <p>The first is the certificate is specific to my company (i.e. the subject is specific to my company).</p>
  
  <p>The second certificate is the certificate for the issuer.</p>
  
  <p>It looks something like this...</p>
  
  <pre><code>Bag Attributes
      localKeyID: 01 00 00 00 
      friendlyName: CCAPI Client Certificate
  Key Attributes
      X509v3 Key Usage: 10
  -----BEGIN RSA PRIVATE KEY-----
  &lt;&lt;contents&gt;&gt;
  -----END RSA PRIVATE KEY-----
  Bag Attributes
      localKeyID: 01 00 00 00
      friendlyName: CCAPI Client Certificate
      subject=MyCompany CN/OU/O/L/ST/C
      issuer=Issuer CN/OU/O/L/ST/C
  -----BEGIN CERTIFICATE-----
  &lt;&lt;contents&gt;&gt;
  -----END CERTIFICATE-----
  Bag Attributes
      localKeyID: 02 00 00 00
      subject=Issuer CN/OU/O/L/ST/C
      issuer=Issuer CN/OU/O/L/ST/C
  -----BEGIN CERTIFICATE-----
  &lt;&lt;contents&gt;&gt;
  -----END CERTIFICATE-----
  </code></pre>
  
  <p>Firstly I'd like to confirm a couple of things.</p>
  
  <p>Terminology wise is it correct to say I have a pem file with two certificates? How do I describe the PRIVATE KEY part? Is that the public key of the server I am trying to connect to?</p>
  
  <p>And secondly I need to use the keytool command to create a java keystore file (jks) with both certificate and the issue certificate in it.</p>
  
  <p>Can someone help me with the commands to do that. I'm spent a lot of time googling but there seems to be a lot of varying use cases out there which is confusing me.</p>
  
  <p>thanks in advance</p>