如何编写 makecert“-sky Exchange”代码?和“-sky签名”在 C# 中
我需要以编程方式在 .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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我意识到您现在可能已经找到了解决方案,但代码如下所示:(基于 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\"");