gpt4 book ai didi

java - X509 扩展

转载 作者:太空宇宙 更新时间:2023-11-04 12:31:54 29 4
gpt4 key购买 nike

如何使用 bouncycaSTLe API 在 java 中设置 x509 证书的扩展?

我设法做到了这样的“基本约束”:

...
X509V3CertificateGenerator gen = new X509V3CertificateGenerator();
...
boolean crit;
boolean isCa;
gen.addExtension(X509Extensions.BasicConstraints, crit, new BasicConstraints(isCa));

但是,我不知道如何对 IssuerAlternativeNameKeyUsage 执行相同操作。

最佳答案

试试这个

 KeyUsage usage = new KeyUsage(KeyUsage.keyCertSign
| KeyUsage.digitalSignature | KeyUsage.keyEncipherment
| KeyUsage.dataEncipherment | KeyUsage.cRLSign);
gen.addExtension(Extension.keyUsage, false, usage);


GeneralNames issuerAltName = new GeneralNames(new GeneralName(new X509Name("CN=somedomain.tld")));
gen.addExtension(X509Extensions.IssuerAlternativeName, false, issuerAltName);

关于java - X509 扩展,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37789137/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com