可能重复:
使用 Java 生成证书、公钥和私钥
我想使用 Java 代码生成私钥和自签名证书并将其导出到文件中。当我通过网络搜索时,我只能通过 openssl 或 keytool 命令获得详细信息,而不是通过 java 代码。我不想使用任何第三方库。
下面是创建密钥和自签名证书的命令,我想使用 java 代码来做同样的事情。
openssl req -new -text -out server.req
openssl rsa -in privkey.pem -out server.key
openssl req -x509 -in server.req -text -key server.key -out server.crt
任何形式的帮助或建议将不胜感激。