How can I do that in bouncyCastle (get installed certificates)?

℡╲_俬逩灬. 提交于 2019-12-10 04:54:46

问题


Ok, I am quite new to the crypto world of bouncyCastle, and perhaps is a mental block, I can't seem to find(/google for) the equivalent to:

X509Store store = 
new X509Store(StoreName.My, StoreLocation.CurrentUser);
store.Open(OpenFlags.ReadOnly);

I think it might be the easiest and dumbest thing, but how can I access the windows installed certificates, using bouncy castle?

Or if I can't, how can i convert my System.Security.Cryptography.X509Certificates.X509Certificate2 to Org.BouncyCastle.X509.X509Certificate?


回答1:


Bouncycastle doesn't have access to Windows certificates store, that is the role of Microsoft's .NET classes. To convert between .NET certificates and their Bouncycastle equivalents look at the methods in the Org.BouncyCastle.Security.DotNetUtilities class, particularly the ToX509Certificate and FromX509Certificate methods.




回答2:


I convert the System.Security.Cryptography.X509Certificates.X509Certificate2 to a Org.BouncyCastle.X509.X509Certificate using the following method

public static org.bouncycastle.x509.X509Certificate 
        convertToBCX509Certificate(X509Certificate2 cert) {

    X509CertificateParser parser = 
            new X509CertificateParser(cert.Export(X509ContentType.Cert));
    return parser.ReadCertificate();

}


来源:https://stackoverflow.com/questions/6549565/how-can-i-do-that-in-bouncycastle-get-installed-certificates

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!