Search in sources :

Example 1 with CertExtension

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()));
        }
    }
}
Also used : CertExtension(com.github.zhenwei.sdk.builder.params.CertExtension) ASN1ObjectIdentifier(com.github.zhenwei.core.asn1.ASN1ObjectIdentifier)

Example 2 with CertExtension

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);
}
Also used : KeyBuilder(com.github.zhenwei.sdk.builder.KeyBuilder) KeyPair(java.security.KeyPair) CertExtension(com.github.zhenwei.sdk.builder.params.CertExtension) WeGooProvider(com.github.zhenwei.provider.jce.provider.WeGooProvider) ArrayList(java.util.ArrayList) P10Builder(com.github.zhenwei.sdk.builder.P10Builder) Test(org.junit.Test)

Aggregations

CertExtension (com.github.zhenwei.sdk.builder.params.CertExtension)2 ASN1ObjectIdentifier (com.github.zhenwei.core.asn1.ASN1ObjectIdentifier)1 WeGooProvider (com.github.zhenwei.provider.jce.provider.WeGooProvider)1 KeyBuilder (com.github.zhenwei.sdk.builder.KeyBuilder)1 P10Builder (com.github.zhenwei.sdk.builder.P10Builder)1 KeyPair (java.security.KeyPair)1 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1