最好的办法,从x509Certificate2 initaite的RSACryptoServiceProvider? [英] Best way to initaite RSACryptoServiceProvider from x509Certificate2?

查看:327
本文介绍了最好的办法,从x509Certificate2 initaite的RSACryptoServiceProvider?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是initate从一个新的的RSACryptoServiceProvider 对象,最好的办法是 X509Certificate2 我掏出钥匙店?该证书与公共(加密)和私人(解密)密钥相关联。

我目前使用 FromXmlString 的方法,但必须有一个更好的办法。

感谢

解决方案

 的RSACryptoServiceProvider publicKeyProvider =
    (的RSACryptoServiceProvider)certificate.PublicKey.Key;
 

 的RSACryptoServiceProvider privateKeyProvider =
    (的RSACryptoServiceProvider)certificate.PrivateKey;
 

在证书上的公共或私有密钥属性的关键属性的类型AsymmetricAlgorithm的。

What is the best way to initate a new RSACryptoServiceProvider object from an X509Certificate2 I pulled out of a key store? The certificate is associated with both public (for encryption) and private (for decryption) keys.

I'm current using the FromXmlString method but there must be a better way.

Thanks

解决方案

RSACryptoServiceProvider publicKeyProvider = 
    (RSACryptoServiceProvider)certificate.PublicKey.Key;

and

RSACryptoServiceProvider privateKeyProvider = 
    (RSACryptoServiceProvider)certificate.PrivateKey;

The key property on the public or private key property of the certificate is of type AsymmetricAlgorithm.

这篇关于最好的办法,从x509Certificate2 initaite的RSACryptoServiceProvider?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆