code: public PKCS10CertificationRequest createSigningRequest(PrivateKey privateKey,
              PublicKey publicKey, String subjectString) {
          try {
              logger.entry();
  
              logger.debug("Creating the CSR...");
              X500Principal subject = new X500Principal(subjectString);
              ContentSigner signer = new JcaContentSignerBuilder(ASYMMETRIC_SIGNATURE_ALGORITHM).build(privateKey);
              PKCS10CertificationRequest result = new JcaPKCS10CertificationRequestBuilder(subject, publicKey)
                      .setLeaveOffEmptyAttributes(true).build(signer);
  
              logger.exit();
              return result;
  
          } catch (OperatorCreationException e) {
              RuntimeException exception = new RuntimeException("An unexpected exception occurred while attempting to generate a new certificate signing request.", e);
              logger.error(exception.toString());
              throw exception;
          }
      }
docs: This method creates a new certificate signing request (CSR) using the specified key pair
  and subject string.  This is a convenience method that really should be part of the
  <code>CertificateManagement</code> interface except that it depends on a Bouncy Castle
  class in the signature.  The java security framework does not have a similar class so it
  has been left out of the interface.
  
  @param privateKey The private key to be used to sign the request.
  @param publicKey The corresponding public key that is to be wrapped in the new certificate.
  @param subjectString The subject string to be included in the generated certificate.
  
  @return The newly created CSR.