可能重複:
Generate certificates, public and private keys with JavaJava代碼來生成私鑰和自簽名證書
我要生成私鑰和自簽名證書使用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
任何形式的幫助或建議將非常感激。
你有沒有看着 http://stackoverflow.com/questions/4634124/how -to-生成點登錄和-i的mport-ssl-certificate-from-java?lq = 1 and http://stackoverflow.com/questions/925377/generate-certificates-public-and-private-keys-with-java?rq=1 ? – user1890278
我強烈建議使用BouncyCastle(http://www.bouncycastle.org/latest_releases.html)。 – Pr0gr4mm3r
看看這個[page](http://www.mayrhofer.eu.org/create-x509-certs-in-java)。 – Codo