public PKCS10 createCSRequest(Device device,KeyPair keyPair) throws KeyStoreException {
  X500Name x500Name=createX500NameForDevice(device);
  PKCS10 request=null;
  try {
    request=new PKCS10(keyPair.getPublic());
    Signature signature=Signature.getInstance("MD5withRSA");
    signature.initSign(keyPair.getPrivate());
    request.encodeAndSign(x500Name,signature);
  }
 catch (  Exception e) {
    throw new KeyStoreException("Unable to create CSR request",e);
  }
  return request;
}

public PKCS10 createCSRequest ( Device device , KeyPair keyPair ) throws KeyStoreException { X500Name x500Name = createX500NameForDevice ( device ) ; PKCS10 request = null ; try { request = new PKCS10 ( keyPair . getPublic ( ) ) ; Signature signature = Signature . getInstance ( "MD5withRSA" ) ; signature . initSign ( keyPair . getPrivate ( ) ) ; request . encodeAndSign ( x500Name , signature ) ; } catch ( Exception e ) { throw new KeyStoreException ( "Unable to create CSR request" , e ) ; } return request ; }
creates a certificate signing request and signs it with rsa private key
