title: Unable to access my X509Certificate2's PrivateKey In Azure
body: <p>I have my X509Certificate stored in a database (in <code>byte[]</code>) so that my application can retrieve the certificate and use it to sign my JWTs.</p>
  
  <p>My x509Certificate is passed off a .pfx file that I generated on my machine, however now it sits in a database as a string of bytes.</p>
  
  <p>My application works perfectly fine locally when I run it. The application can correctly create an instance of that X509Certificate2 and use it for my requirements, however the problem arises when I try to use it in my azurewebsites web application.</p>
  
  <p>Basically I can not access the certificates' PrivateKey instance variable, I get an exception</p>
  
  <pre><code>System.Security.Cryptography.CryptographicException: Keyset does not exist
  </code></pre>
  
  <p>And I am re-instantiating the certificate with this</p>
  
  <pre><code>var cert = new X509Certificate2(myCertInBytes, myCertPass,
              X509KeyStorageFlags.PersistKeySet |
              X509KeyStorageFlags.MachineKeySet |
              X509KeyStorageFlags.Exportable);
  </code></pre>
  
  <p>I am using ASPNET 5 rc1-update1. I have also tried running this on a different machine and it works fine, only have this issue when I publish to Azure. And to also add something else, This application was working when I was running the same project that was running using DNX version beta7</p>
  
  <p>Any help appreciated.</p>