从 pfx 文件中提取公钥(类似汇编)
我在从 PFX 文件中提取公钥时遇到问题。我使用的第一件事是 X509Certificate2。然而,以这种方式收到的公钥是加密的,我希望这个密钥能够兼容 InternalsVisibleTo 属性 - 示例 /em> 部分有此类密钥的示例。有没有办法以兼容的形式提取此密钥(与InternalsVisibleTo兼容)。
I have a problem with extraction of public key from PFX file. First thing which i have used is X509Certificate2. However public key received in this way is encrypted, and i want to have this key to be compatible with
InternalsVisibleTo Attribute - In Examples section there is an sample of such key. Is there a way to extract this key in compatible form (Compatible to InternalsVisibleTo).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这只是一个格式问题,即X509Certificate2应该返回解密的公钥(或者失败,例如密码错误)。
我建议您遵循 Mono 对强名称程序集所做的操作,即它自己的 sn 工具。虽然 Mono 的 sn.exe 不直接读取 PKCS#12 文件,但它可以从密钥容器中读取,因此在这两种情况下您最终都会得到一个 RSACryptoServiceProvider。
只需深入查看源代码,它就是全部是 C#,而且不是很长,您会在那里找到您需要的内容(或者在涉及的少数帮助程序类之一中)。
It's simply a formatting issue, i.e. X509Certificate2 should return you the decrypted public key (or fail, e.g. bad password).
I suggest you to follow what Mono does to strong name assemblies, i.e. its own sn tool. While Mono's sn.exe does not directly read PKCS#12 files it can read from key containers, so you end up with a RSACryptoServiceProvider in both case.
Just drill down into the source code, it's all C# and not very long, and you'll find what you need there (or in one of the few helper classes that are involved).