use of com.github.zhenwei.sdk.builder.KeyStoreBuilder in project LinLong-Java by zhenwei1108.
the class KeyStoreTest method genJks.
@Test
public void genJks() throws Exception {
KeyStoreBuilder builder = new KeyStoreBuilder();
KeyBuilder keyBuilder = new KeyBuilder(new WeGooProvider());
KeyPair keyPair = keyBuilder.buildKeyPair(KeyPairAlgEnum.SM2_256);
P10Builder p10Builder = new P10Builder("C=CN,CN=demo,O=zhenwei", keyPair.getPublic(), keyPair.getPrivate(), null);
byte[] certificate = CertBuilder.generateCertificate("C=CN,CN=demo,O=zhenwei", "C=CN,CN=demo", keyPair.getPublic(), keyPair.getPrivate());
System.out.println("证书:" + Base64Util.encode(certificate));
System.out.println(Hex.toHexString(keyPair.getPrivate().getEncoded()));
X509Certificate cert = CertBuilder.getInstance(certificate).getCert();
byte[] jks = builder.genJks(keyPair.getPrivate(), "test", "123123", new Certificate[] { cert });
System.out.println(Hex.toHexString(jks));
}
Aggregations