I've recently tried to jump into the wonderful world of the Google Analytics API and, for the life of me, can't get the P12 key path to be picked up in a location relative to my solution file, so (this is what I have so far):
var certificate = new X509Certificate2("C:\\mykey.p12", "notasecret", X509KeyStorageFlags.MachineKeySet | X509KeyStorageFlags.Exportable);
This works fine, no problem! But, I'll be pushing this to Azure, so C:\ simply won't work.
I've tried:
var certificate = new X509Certificate2("mykey.p12", "notasecret", X509KeyStorageFlags.MachineKeySet | X509KeyStorageFlags.Exportable);
with the key in the root path of my solution, nada, this simply won't work. I've been scouring tutorials out there with people saying it's possible, but not providing anything about how the key was referenced locally to the solution so it'll work on Azure (with MachineKeySet).
Thanks in advance.
var certificate = new X509Certificate2("mykey.p12", "notasecret", X509KeyStorageFlags.MachineKeySet | X509KeyStorageFlags.Exportable);
would work if your certificate was loaded into your bin folder. So set the certificates build action to 'Content' and its Copy to Output Directory to 'Copy if newer'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With