code: public byte[] createCertificateRequest(X509Name subjectDN, String sigAlgName, KeyPair keyPair)
          throws GeneralSecurityException {
          DERSet attrs = null;
          PKCS10CertificationRequest certReq = null;
          certReq = new PKCS10CertificationRequest(sigAlgName, subjectDN, keyPair.getPublic(), attrs, keyPair
              .getPrivate());
  
          return certReq.getEncoded();
      }
docs: Creates a certificate request from the specified subject name, signing algorithm, and a key pair.
  
  @param subjectDN
  the subject name of the certificate request.
  @param sigAlgName
  the signing algorithm name.
  @param keyPair
  the key pair of the certificate request
  @return the certificate request.
  @exception GeneralSecurityException
  if security error occurs.