Public static void main (string [] ARGs) {string subjectdn = "cn = duwenlei"; string algorithm = ""; try {keypairgenerator = keypairgenerator. getinstance ("RSA"); keypairgenerator. initialize (2048); keypair = keypairgenerator. generatekeypair (); algorithm = keypair. getprivate (). getalgorithm (); pkcs10certificationrequestbuilder builder = new pkcs10certificationrequestbuilder (New x500name (subjectdn), subjectpublickeyinfo. getinstance (keypair. getpublic (). getencoded (); jcacontentsignerbuilder jcabuilder = new jcacontentsignerbuilder ("sha1withrsa"); // jcabuilder. setprovider (provider); you can add the provider contentsigner = jcabuilder. build (keypair. getprivate (); builder. build (contentsigner); system. out. println (builder. tostring ();} catch (nosuchalgorithmexception e) {e. printstacktrace ();} catch (operatorcreationexception e) {e. printstacktrace ();}}
Need to use the package: bcmail-jdk15-1.46.jar, bcprov-jdk15-1.46.jar, with less than: bctsp-jdk15-1.46.jar