Why wouldn't an app recognize a Certificate with a CSP of "Microsoft Software Key Storage Provider"...
David Gursky
0
Reputation points
...but will recognize the same Cert with the CSP set to "Microsoft Enhanced RSA and AES Cryptographic Provider"?
In other words, the app fails when I import the certificate into the server's local key store like this:
certutil.exe -importpfx <certificate file path>\<certificate file>
but works if I override the CSP like this:
certutil.exe -csp "Microsoft Enhanced RSA and AES Cryptographic Provider" -importpfx <certificate file path>\<certificate file>
Here is the relevant section of code:
var store2 = X509CertificateStore.LocalMachineStore(X509CertificateStore.MyStore);
store2.OpenRead();
var coll2 = store2.FindCertificateBySubjectString(ConfigurationManager.AppSettings["<redacted>"]);
if (coll2.Count > 0) {
var cert2 = coll2[0];
var certType = cert2.GetType();
var cert3 = new X509Certificate2(cert2);
certType = cert3.GetType();
if (cert2.SupportsDigitalSignature) {
svc.ClientCredentials.ClientCertificate.Certificate = new X509Certificate2(cert2);
}
}
else throw new Exception("Certificate attachment failed.");
var currentUser = SessionHelper.CurrentUser;
var svcAddress = Settings.Default.App_Service_WebService;
results = svc.getresultsByPersonIdentifier(PersonIdentifier.Text, identifier.PI, out responseCd, out responseMsg);
The code throws an Invalid Service Provider when it invokes the web service at the end of the snippet.
Sign in to answer