更改 x509 扩展属性/用法
Is there any way to programmatically edit the purposes enabled for a give x.509 certificate?
This functionality is available via the certificates mmc snap-in (hyperlink below) but I need to perform the action through code. preferably C#.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
MMC 可以执行 Crypto API 可以执行的任何操作,并且有许多与证书相关的函数,例如 CertAddEnhancedKeyUsageIdentifier 或 CertSetCertificateContextProperty。 示例 C 程序:获取和设置证书属性,包括修改“增强密钥用途”,指定证书有效的用途。例如,要使服务器端的证书对 SSL 有效,您必须添加 EKU OID
1.3.6.1.5.5.7.3.1
(又名“服务器身份验证”),请参阅< a href="http://msdn.microsoft.com/en-us/library/ms186362.aspx" rel="nofollow noreferrer">配置 SSL 使用的证书。C# 等效项是 X509KeyUsageExtension班级。有关示例,请参阅类规范的链接。
The MMC can do whatever the Crypto API can do and there are a bunch of Certificate related functions like CertAddEnhancedKeyUsageIdentifier or CertSetCertificateContextProperty. There is a full blown example at Example C Program: Getting and Setting Certificate Properties, including a modification of the 'enhanced key usage' that specifies the uses for which a certificate is valid. For instance, to make a cert valid for SSL from the server side you'd have to add the EKU OID
1.3.6.1.5.5.7.3.1
(aka. 'Server Authentication'), see Configuring Certificate for Use by SSL.The C# equivalent is the X509KeyUsageExtension class. See the link to the class spec for examples.