通過C#來加載X509格式證書文件並生成RSA對象


private static RSACryptoServiceProvider GetPrivateKey(string priKeyFile, string keyPwd)
{
    var pc = new X509Certificate2(priKeyFile, keyPwd, X509KeyStorageFlags.MachineKeySet);
    return (RSACryptoServiceProvider) pc.PrivateKey;
}

private static RSACryptoServiceProvider GetPublicKey(string pubKeyFile)
{
    var pc = new X509Certificate2(pubKeyFile);
    return (RSACryptoServiceProvider) pc.PublicKey.Key;
}

*.cer格式公鑰證書及*.pfx格式私鑰證書


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM