从 DEROctetString 到 KeyUsage
在 bouncycastle 中,我可以从 KeyUsage 开始创建 DEROctetString。
那么如何从 DEROctetString 开始获取 KeyUsage 呢?
示例:
DEROctetString derString = new DEROctetString(new KeyUsage(KeyUsage.digitalSignature));
KeyUsage ku = ...(some code to get back KeyUsage starting from derString)...
我需要这个,因为我能够使用 KeyUsage 扩展请求创建证书请求,但是,仅考虑证书请求,我无法取回 KeyUsage 扩展。
In bouncycastle I can create a DEROctetString starting from a KeyUsage.
How can I obtain KeyUsage starting from a DEROctetString then?
Example:
DEROctetString derString = new DEROctetString(new KeyUsage(KeyUsage.digitalSignature));
KeyUsage ku = ...(some code to get back KeyUsage starting from derString)...
I need this because I'm able to create Certificate Requests with KeyUsage extension request, but then, given the Certificate Request alone, I'm not able to get back the KeyUsage extension.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我找到了使用 ASN1InputStream 的解决方案:
有效!
I've found the solution using ASN1InputStream:
That works!
KeyUsage在X.509中是这样定义的,
所以为其创建Octet String是错误的。如果您创建 DERBitString,KeyUsage 有一个它的构造函数。
KeyUsage is defined as this in X.509,
So it's wrong to create Octet String for it. If you create DERBitString, KeyUsage has a constructor for it.