use of com.github.zhenwei.sdk.builder.params.CertExtension in project LinLong-Java by zhenwei1108.
the class P10Builder method parseExtension.
/**
* @param [list]
* @return com.github.zhenwei.core.asn1.ASN1EncodableVector
* @author zhangzhenwei
* @description parseExtension 解析扩展项
* @since: 1.0.0
* @date 2022/2/21 10:33 下午
*/
private void parseExtension(List<CertExtension> list, PKCS10CertificationRequestBuilder builder) throws WeGooCryptoException {
if (list != null) {
for (CertExtension certExtension : list) {
ASN1ObjectIdentifier oid = new ASN1ObjectIdentifier(certExtension.getKey());
builder.addAttribute(oid, CodingType.encode(certExtension.getCodingType(), certExtension.getValue()));
}
}
}
use of com.github.zhenwei.sdk.builder.params.CertExtension in project LinLong-Java by zhenwei1108.
the class P10Test method genP10.
@Test
public void genP10() throws Exception {
WeGooProvider provider = new WeGooProvider();
KeyBuilder keyBuilder = new KeyBuilder(provider);
KeyPair keyPair = keyBuilder.buildKeyPair(KeyPairAlgEnum.SM2_256);
List<CertExtension> list = new ArrayList<>();
CertExtension certExtension = new CertExtension("1.2.3", "demo1111".getBytes(StandardCharsets.UTF_8), CodingType.DEROCTETSTRING);
list.add(certExtension);
P10Builder p10Builder = new P10Builder("C=CN,CN=TEST", keyPair.getPublic(), keyPair.getPrivate(), list);
String p10 = p10Builder.getP10();
System.out.println(p10);
}
Aggregations