title: Help with SAML error: "Keyset does not exist"
body: <p>We have two environments that should be identical but one of them raises an error when we try to generate a SAML message signature. I haven't looked at SAML before and I am not exactly sure what it tries to do</p>
  
  <p>Part of the code:</p>
  
  <pre><code>X509Certificate2 x509Certificate = (X509Certificate2)Application[ASP.global_asax.IdPX509Certificate];
  
          try
          {
              SAMLMessageSignature.Generate(samlResponse, x509Certificate.PrivateKey, x509Certificate);
          }
          catch (Exception ex)
          {
              app = File.AppendText(@"C:\SAML.txt");
              app.WriteLine(ex.Message.ToString());
              app.Flush();
              app.Close();
          }
  </code></pre>
  
  <p>The exception message is </p>
  
  <blockquote>
    <p>Keyset does not exist</p>
  </blockquote>
  
  <p>Does anyone have any idea of what I should be looking at?</p>
  
  <p>Thanks in advance.</p>