.net - Cannot read X509 certificates from certificate store in a web application -
i cannot see x509 certificates when running code web application:
var store = new x509store(storename.root, storelocation.localmachine); store.open(openflags.readonly); string thumbprint = webconfigurationmanager.appsettings["certificatethumbprint"]; if (string.isnullorwhitespace(thumbprint)) { throw new argumentexception("please specify x509 certificate thumbprint in web configuration file."); } certificate = store.certificates .find(x509findtype.findbythumbprint, thumbprint, true) .oftype<x509certificate2>() .firstordefault(); store.close(); if (certificate == null) { throw new argumentexception("the specified x509 certificate has not been installed on server."); }
when debugging, can see store.certificates
empty. however, runs in console app.. odd because have seen examples online using above code in web application.
it helpful if code throw kind of permission exception or web app tell me why can't read them, doesn't. so, there permissions need set somewhere or what?
i set certificate in trustedpeople store instead , works fine:
var store = new x509store(storename.trustedpeople, storelocation.localmachine);
.net security cryptography
No comments:
Post a Comment