在 Java 中以编程方式设置主题备用名称 [英] Set Subject Alternative Names programmatically in Java

查看:42
本文介绍了在 Java 中以编程方式设置主题备用名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用类似于此代码的东西.如何使用 sun.security 以编程方式在我的证书中添加设置 主题备用名称?

I am using something similar to this code. How can I add set the Subject Alternative Names in my certificate programmatically using sun.security?

推荐答案

好吧,追踪多个来源有点棘手,但这里是线索(以防将来它可以帮助任何人,因为我在其他时候得到了帮助):

OK, it was a bit tricky to trace several sources but here it is the clue (in case it can help anyone in future as I have been helped other times):

CertificateExtensions ext = new CertificateExtensions();

ext.set(SubjectAlternativeNameExtension.NAME, new SubjectAlternativeNameExtension(....*));

// * a `GeneralNames` object including a `GeneralName` object including (for example) an `IPAddressName` object.

然后将对象ext传递给证书的构造函数.

And then pass the object ext to the constructor of the certificate.

这篇关于在 Java 中以编程方式设置主题备用名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆