title: import key pair to pfx file without certificate chain in java
body: <pre><code>//Generate key pair
  KeyPair pair = keyGen.generateKeyPair();
  
  //Open a keystore
  KeyStore ks = KeyStore.getInstance("PKCS12");
  ks.load(null, null);
  
  //Setting a key entry
  ks.setKeyEntry("test", pair.getPrivate(), password, **new Certificate[]{cert}**);
  </code></pre>
  
  <p>if i pass <strong>null</strong> instead of new Certificate[]{cert} or if i pass <strong>new Certificate[]{}</strong> i'm getting an error saying <strong>"Private key must be accompanied by certificate chain"</strong>.</p>
  
  <p>So, without passing a certificate chain how can i import the key pair into pfx file.</p>