java 生成csr
Recently I had to write a program to generate Certificate Signing Request (CSR) using Java API. Here I am providing the steps I followed with Java Program to generate CSR. After that, we will also make sure that it’s valid by validating it with VeriSign CSR validator tool.
最近,我不得不编写一个程序来使用Java API生成证书签名请求(CSR)。 在这里,我提供了Java程序生成CSR所遵循的步骤。 之后,我们还将通过使用VeriSign CSR验证器工具对其进行验证来确保其有效。
在Java中以编程方式生成CSR的步骤 (Steps to Generate CSR Programmatically in Java)
- Get instance of KeyPairGenerator using standard encryption algorithm. I am using RSA here. 使用标准加密算法获取KeyPairGenerator的实例。 我在这里使用RSA。
- Initialize the instance by providing keysize and source of randomness. 通过提供密钥大小和随机性来源来初始化实例。
- Generate the PrivateKey and PublicKey that will be used in generating CSR. 生成将在生成CSR中使用的PrivateKey和PublicKey。
- Initialize PKCS10 using the PublicKey. 使用PublicKey初始化PKCS10。
- Get instance of Signature using standard algorithm. I am using MD5WithRSA in my case. 使用标准算法获取签名实例。 我正在使用MD5WithRSA。
- Initialize the signature object using the PrivateKey. 使用PrivateKey初始化签名对象。
- Create X500Name object by passing Common Name, Organization Unit, Organization, Location, State and Country 通过传递通用名称,组织单位,组织,位置,州和国家/地区来创建X500Name对象
- Encode and Sign the PKCS10 object using X500Signer, Signature and X500Name object 使用X500Signer,Signature和X500Name对象对PKCS10对象进行编码和签名
- Print the PKCS10 object to PrintStream. After that you can save it in file or print in console 将PKCS10对象打印到PrintStream。 之后,您可以将其保存在文件中或在控制台中打印