x509 Certificate installation using VB.NET

孤者浪人 提交于 2019-12-06 15:01:34

Use the X509Certificate2Collection class like this:

Dim collection = New X509Certificate2Collection()

collection.Import(.FileName, "xxxxxxx", X509KeyStorageFlags.UserKeySet)

Dim store = New X509Store(StoreName.My, StoreLocation.CurrentUser)

store.Open(OpenFlags.ReadWrite)

Try
    For Each certificate As X509Certificate2 In collection
        store.Add(certificate)
    Next
Finally
    store.Close()
End Try

This allows you to import all the certificates from the file.

Please note that the right place for CA certificates is the Trusted Root Certification Authorities folder. And you only should import certificates there if you trust the issuer.

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