Class PKCGenerate
java.lang.Object
org.ofdrw.gm.cert.PKCGenerate
生成测试的公私钥对和证书
P12文件
PK - Public Key and Private Key Pair
C - Certificate
- Since:
- 2020-04-21 09:37:10
- Author:
- 权观宇
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic org.bouncycastle.pkcs.PKCS10CertificationRequestCertRequest(KeyPair kp, org.bouncycastle.asn1.x500.X500Name subject) 生成SM2密钥对的证书请求(pkcs10格式)static X509CertificateGenCert(org.bouncycastle.pkcs.PKCS10CertificationRequest p10Obj, Certificate root, PrivateKey privateKey) 签发证书static KeyPair生成测试SM2密钥对static voidSaveToPKCS12(KeyPair pk, Certificate[] certs, String pwd, Path outP) 生成P12存储文件static org.bouncycastle.asn1.x500.X500NameTestND()
-
Constructor Details
-
PKCGenerate
public PKCGenerate()
-
-
Method Details
-
TestND
public static org.bouncycastle.asn1.x500.X500Name TestND()- Returns:
- 证书请求识别名称 (也就是证书的Subject)
-
CertRequest
public static org.bouncycastle.pkcs.PKCS10CertificationRequest CertRequest(KeyPair kp, org.bouncycastle.asn1.x500.X500Name subject) throws org.bouncycastle.operator.OperatorCreationException 生成SM2密钥对的证书请求(pkcs10格式)- Parameters:
kp- SM2密钥对subject- 证书使用者- Returns:
- 证书请求
- Throws:
org.bouncycastle.operator.OperatorCreationException- 操作异常
-
GenerateKeyPair
生成测试SM2密钥对- Returns:
- 密钥对
- Throws:
GeneralSecurityException- 安全操作异常
-
GenCert
public static X509Certificate GenCert(org.bouncycastle.pkcs.PKCS10CertificationRequest p10Obj, Certificate root, PrivateKey privateKey) throws GeneralSecurityException, IOException, org.bouncycastle.operator.OperatorCreationException 签发证书- Parameters:
p10Obj- 证书请求ASN1对象root- CA根证书privateKey- CA私钥- Returns:
- X509证书对象
- Throws:
GeneralSecurityException- 安全操作异常IOException- 文件读写异常org.bouncycastle.operator.OperatorCreationException- 操作异常
-
SaveToPKCS12
public static void SaveToPKCS12(KeyPair pk, Certificate[] certs, String pwd, Path outP) throws GeneralSecurityException, IOException 生成P12存储文件存储公私钥对以及证书
- Parameters:
pk- 密钥对certs- 证书链pwd- P12密码outP- 保存位置- Throws:
GeneralSecurityException- 安全异常IOException- IO异常
-