title: Get PrivateKey from X509Certificate
body: <p>Here is my code to generate a SSL certificate using Let's Encrypt (based on <a href="https://github.com/zero11it/acme-client" rel="nofollow noreferrer">https://github.com/zero11it/acme-client</a>):</p>
  
  <pre><code>AcmeChallengeListener challengeListener = new HttpChallengeListener(sessionToken, appObjectId, userId, domains[0], "");
  Acme acme = new Acme(CA_STAGING_URL, new DefaultCertificateStorage(true), true, true);
  X509Certificate cert = acme.getCertificate(domains, AGREEMENT_URL, contacts, challengeListener);
  String fullchain = CertificateHelper.x509ToBase64PEMString(cert);
  </code></pre>
  
  <p>Is there a way to get the <code>PrivateKey</code> and also get it as String with the <code>-----BEGIN PRIVATE KEY-----</code> and <code>-----END PRIVATE KEY-----</code>? So it can be uploaded by our app to our NGINX server.</p>