title: Generate CSR from private key or Key Store
body: <p>How can i generate CSR from the Key Store.</p>
  
  <p>I have generated CSR from key pair. Below is my code.</p>
  
  <pre><code>public static PKCS10CertificationRequest generateCSR(KeyPair keyPair, String cn) throws IOException,
          OperatorCreationException {
      String principal = String.format(CN_PATTERN, cn);
  
      ContentSigner signer = new JCESigner (keyPair.getPrivate(),DEFAULT_SIGNATURE_ALGORITHM);
  
      PKCS10CertificationRequestBuilder csrBuilder = new JcaPKCS10CertificationRequestBuilder(
              new X500Name(principal), keyPair.getPublic());
      ExtensionsGenerator extensionsGenerator = new ExtensionsGenerator();
      extensionsGenerator.addExtension(Extension.basicConstraints, true, new BasicConstraints(
              true));
      csrBuilder.addAttribute(PKCSObjectIdentifiers.pkcs_9_at_extensionRequest,
              extensionsGenerator.generate());
      Log.e("csr builder ","csr "+csrBuilder.toString());
      PKCS10CertificationRequest csr = csrBuilder.build(signer);
  
      return csr;
  }
  </code></pre>
  
  <p>But i cannot generate CSR from Keystore(Private Key).
  Is there any way i can generate key pair from Keystore?</p>
  
  <p>Please help me.Thanks in Advance.</p>