How to set read permission on the private key file of X.509 certificate from .NET

前端 未结 6 1356
遥遥无期
遥遥无期 2020-11-28 07:12

Here is the code to add a pfx to the Cert store.

X509Store store = new X509Store( StoreName.My, StoreLocation.LocalMachine );
store.Open( OpenFlags.ReadWrite         


        
6条回答
  •  自闭症患者
    2020-11-28 07:34

    To do it programmatically, you have to do three things:

    1. Get the path of the private key folder.

    2. Get the file name of the private key within that folder.

    3. Add the permission to that file.

    See this post for some example code that does all three (specifically look at the "AddAccessToCertificate" method).

提交回复
热议问题