是否使用AllowPlaintextExport标志将C#X509Certificate2添加到X509Store?
当我使用CertUtil将证书导入到存储中时,例如,是否使用AllowPlaintextExport标志将C#X509Certificate2添加到X509Store?,c#,.net,x509certificate,x509certificate2,cng,C#,.net,X509certificate,X509certificate2,Cng,当我使用CertUtil将证书导入到存储中时,例如,CertUtil-f-v-user-privatekey-importPFX my mycert.p12,然后在C中读取它,我看到它的导出策略是AllowExport | AllowPlaintextExport 但是,当使用X509Store.Add()方法将同一证书导入同一存储,然后将其读回时,导出策略仅为AllowExport;将证书导入存储时,我使用x509keystrageflags.Exportable标志,例如: ... X509
CertUtil-f-v-user-privatekey-importPFX my mycert.p12
,然后在C中读取它,我看到它的导出策略是AllowExport | AllowPlaintextExport
但是,当使用X509Store.Add()
方法将同一证书导入同一存储,然后将其读回时,导出策略仅为AllowExport
;将证书导入存储时,我使用x509keystrageflags.Exportable
标志,例如:
...
X509Certificate2Collection x509cert2Collection = new X509Certificate2Collection();
x509cert2Collection.Import(myp12bytes, passwd, X509KeyStorageFlags.Exportable);
foreach (X509Certificate2 x509cert2 in x509cert2Collection) {
X509Store myStore = new X509Store(StoreName.My, StoreLocation.CurrentUser);
myStore.Add(x509cert2);
myStore.Close();
}
...
我的问题是:是否有办法将X509Certificate2添加到C#中的X509Store中,以使证书的导出策略同时包括AllowExport
和AllowPlaintextExport
?X509keystrageFlags似乎没有定义AllowPlaintextExport
标志;只有CngExportPolicies
可以
仅供参考,我使用.NET Framework 4.6.1作为目标
谢谢。是否有使用此标志的商业案例?我正在导出cng键以创建所述的BouncyCastle键,例如。当使用certutil导入的证书执行此操作时,它会工作,但使用添加了C#API的证书执行此操作时会引发异常。