Bouncycastle create CSR

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.