• bouncycastle创建csr


    public static void main(String[] args) {
            String subjectDN = "CN=duwenlei";
            String algorithm = "";
            try {
                KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("RSA");
                keyPairGenerator.initialize(2048);
                KeyPair 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); 这里可以添加提供者
                ContentSigner contentSigner = jcaBuilder.build(keyPair.getPrivate());
                builder.build(contentSigner);
                System.out.println(builder.toString());
            } catch (NoSuchAlgorithmException e) {
                e.printStackTrace();
            } catch (OperatorCreationException e) {
                e.printStackTrace();
            }
    
        }

    需要用到的包:bcmail-jdk15-1.46.jar,bcprov-jdk15-1.46.jar,用不到:bctsp-jdk15-1.46.jar

    如果有使用请标明来源:http://www.cnblogs.com/duwenlei/
  • 相关阅读:
    数据库事务的四大特性以及事务的隔离级别
    informer使用示例
    Linux内存、Swap、Cache、Buffer详细解析
    浏览器访问百度的整个过程
    安装zookeeper
    配置java环境
    promethues开发
    go mod常用操作说明
    redis使用基础
    channel的声明和使用
  • 原文地址:https://www.cnblogs.com/duwenlei/p/3913021.html
Copyright © 2020-2023  润新知