更改 x509 扩展属性/用法

发布于 2024-08-18 16:16:42 字数 207 浏览 2 评论 0原文

有没有办法以编程方式编辑给定 x.509 证书启用的用途?

此功能可通过证书 mmc 管理单元(下面的超链接)使用,但我需要通过代码执行该操作。最好是C#。

修改证书的属性

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#.

modify the properties of a certificate

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

雅心素梦 2024-08-25 16:16:42

MMC 可以执行 Crypto API 可以执行的任何操作,并且有许多与证书相关的函数,例如 CertAddEnhancedKeyUsageIdentifierCertSetCertificateContextProperty示例 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文