c# - Error: 'The system cannot find the file specified.' when trying to access certificate -


i using google api bigquery , requires use .p12 certificate. issue no matter how try import certificate resource keep getting same error:

the system cannot find file specified.

i've added file follows:

var certificate = new x509certificate2(@"key.p12", "notasecret", x509keystorageflags.exportable); 

i'm new c# , visual studio.

in properties window (select p12 file , press f4), ensure 'copy output directory' set 'copy always'. ensure file gets copied ultimate exe location.

basically when say

new x509certificate2(@"key.p12", "notasecret", x509keystorageflags.exportable); 

the code expecting key.p12 file right exe (or dll) running from. has lessto location of file in solution explorer, , more runtime location of file.

also, can try snippet:

var certificate = new x509certificate2(@"key.p12", "notasecret",                                           x509keystorageflags.machinekeyset); 

this because user cert store not loaded asp.net.. machine store is.


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -