如何编写 makecert“-sky Exchange”代码?和“-sky签名”在 C# 中

发布于 2024-11-01 09:07:02 字数 1422 浏览 7 评论 0原文

我需要以编程方式在 .NET 应用程序中创建等效密钥...

makecert -r -pe -a sha1 -n "CN=MyName" -ss my -sr CurrentUser -sky Exchange

makecert -r -pe -a sha1 -n "CN=MyName" -ss my -sr CurrentUser -sky签名

输出最终将像这样使用:

RSACryptoServiceProvider privateKey = new RSACryptoServiceProvider();         
privateKey.FromXmlString("<RSAKeyValue>
<Modulus>wL8s+C8SnnlaaqR+VsyijmxOJOARNa4o7ZNsqfy3+9J9Ol2JNSjjMfQWoUnFtClzJBlZhU5KtuazQe8ZKXTX9YvKoJdRhlsonZkC04qiTMdO/FZIH00GrCRxeQ7XDnQnvPB9Bdsvs//7zrY3f7eLIkpIyK9cQHU+5jjJd5IT0eE=</Modulus>
<Exponent>AQAB</Exponent>
<P>83xxN7jvpg5z16pxz2tIQIdqd/EfmikR9Q2TjG2tosWkUSvtyx0xHZ9EqdTUbSGZZ+jgrabzkafYc7Mplylwew==</P>
<Q>yqcnYSZEXHwJvRWi2V09PNEENTozQZywcFptUUGar9TciaQvoNv3lpnfzUKNBRdhzq4lImxkamajZlTWE5buUw==</Q>
<DP>37HqilkbwyHwB6mOGhPkM3S1ujAK6qTk3JB2iEOTjMGrru9+7maJYz+Z47Wm3ARMXgyzrpZ9m8nqsJFfmoL11Q==</DP>
<DQ>v285tv8kMs2FkZYfuP/oOkwkkneBNejjj68Md2bmzlThZDCyQV2pvB1tmgPVHUsiPNCrCaKlFRISJzfa5rR8Ow==</DQ>
<InverseQ>fgJE2TRe/SS+YqW0/I+FtHrdfbbao0/R3pHD4r4oceZQUemlBgZ7DxOAetebHKthlOdjGkmfWYB8EU4XoWggqw==</InverseQ>
<D>FMLCwjy3wbAKiCANp6XFAJgz1o7365NFv0k41BpvasViTa4TgFFWH2ROJ7M9g0lPqJy+YrhrHcY9mqV5TVjTheQp0JeckrgO2B39XngPMAMMdne3rWGpf0Pfbj3FLfchMk6XYDXSZzCS2CmSeRA4aBMb+4R3YurixyJLrnGRMH0=</D>
</RSAKeyValue>");         

I need to programatically create the equivalant keys in a .NET application...

makecert -r -pe -a sha1 -n "CN=MyName" -ss my -sr CurrentUser -sky exchange

makecert -r -pe -a sha1 -n "CN=MyName" -ss my -sr CurrentUser -sky signature

The output will ultimately be used like this:

RSACryptoServiceProvider privateKey = new RSACryptoServiceProvider();         
privateKey.FromXmlString("<RSAKeyValue>
<Modulus>wL8s+C8SnnlaaqR+VsyijmxOJOARNa4o7ZNsqfy3+9J9Ol2JNSjjMfQWoUnFtClzJBlZhU5KtuazQe8ZKXTX9YvKoJdRhlsonZkC04qiTMdO/FZIH00GrCRxeQ7XDnQnvPB9Bdsvs//7zrY3f7eLIkpIyK9cQHU+5jjJd5IT0eE=</Modulus>
<Exponent>AQAB</Exponent>
<P>83xxN7jvpg5z16pxz2tIQIdqd/EfmikR9Q2TjG2tosWkUSvtyx0xHZ9EqdTUbSGZZ+jgrabzkafYc7Mplylwew==</P>
<Q>yqcnYSZEXHwJvRWi2V09PNEENTozQZywcFptUUGar9TciaQvoNv3lpnfzUKNBRdhzq4lImxkamajZlTWE5buUw==</Q>
<DP>37HqilkbwyHwB6mOGhPkM3S1ujAK6qTk3JB2iEOTjMGrru9+7maJYz+Z47Wm3ARMXgyzrpZ9m8nqsJFfmoL11Q==</DP>
<DQ>v285tv8kMs2FkZYfuP/oOkwkkneBNejjj68Md2bmzlThZDCyQV2pvB1tmgPVHUsiPNCrCaKlFRISJzfa5rR8Ow==</DQ>
<InverseQ>fgJE2TRe/SS+YqW0/I+FtHrdfbbao0/R3pHD4r4oceZQUemlBgZ7DxOAetebHKthlOdjGkmfWYB8EU4XoWggqw==</InverseQ>
<D>FMLCwjy3wbAKiCANp6XFAJgz1o7365NFv0k41BpvasViTa4TgFFWH2ROJ7M9g0lPqJy+YrhrHcY9mqV5TVjTheQp0JeckrgO2B39XngPMAMMdne3rWGpf0Pfbj3FLfchMk6XYDXSZzCS2CmSeRA4aBMb+4R3YurixyJLrnGRMH0=</D>
</RSAKeyValue>");         

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

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

发布评论

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

评论(1

另类 2024-11-08 09:07:02

我意识到您现在可能已经找到了解决方案,但代码如下所示:(基于 http://blogs.technet.com/b/jhoward/archive/2005/02/02/365323.aspx)

Process.Start("makecert .exe", "-pe -n \"CN=MyCert 根权限\" -ss my -sr LocalMachine -a sha1 -sky 签名 -r \"MyCert 根权限.cer\"");

Process.Start("makecert.exe", "-pe -n \"CN=MyCert\" -ss my -sr LocalMachine -a sha1 -sky Exchange -eku 1.3.6.1.5.5.7.3.1 -in \" MyCert 根权限\" -is MY -ir LocalMachine -sp \"Microsoft RSA SChannel 加密提供程序\" -sy 12 \"MyCert.cer\"");

I realize you probably have found a solution by now, but here is what the code would look like: (based on http://blogs.technet.com/b/jhoward/archive/2005/02/02/365323.aspx)

Process.Start("makecert.exe", "-pe -n \"CN=MyCert Root Authority\" -ss my -sr LocalMachine -a sha1 -sky signature -r \"MyCert Root Authority.cer\"");

Process.Start("makecert.exe", "-pe -n \"CN=MyCert\" -ss my -sr LocalMachine -a sha1 -sky exchange -eku 1.3.6.1.5.5.7.3.1 -in \"MyCert Root Authority\" -is MY -ir LocalMachine -sp \"Microsoft RSA SChannel Cryptographic Provider\" -sy 12 \"MyCert.cer\"");

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