title: SAML-2 Cannot create HTTP-REDIRECT binding signature URL parameter
body: <p>From what I understood, if I want to sign the SAML request, the signature should be constructed of: </p>
  
  <p><strong>SAMLRequest=VALUE&amp;RelayState=VALUE&amp;SigAlg=VALUE</strong>
  and from that I should create the signature, this is the piece of code I have used in order to create the signature:</p>
  
  <pre><code>var MSCert = new X509Certificate2(ConfigurationManager.AppSettings["KeyFilepath"], ConfigurationManager.AppSettings["KeyFilePassword"]);
  RSACryptoServiceProvider rsacsp = (RSACryptoServiceProvider)MSCert.PrivateKey;
  CspParameters cspParam = new CspParameters();
  cspParam.KeyContainerName = rsacsp.CspKeyContainerInfo.KeyContainerName;
  cspParam.KeyNumber = rsacsp.CspKeyContainerInfo.KeyNumber == KeyNumber.Exchange ? 1 : 2;
  RSACryptoServiceProvider aescsp = new RSACryptoServiceProvider(cspParam);
  aescsp.PersistKeyInCsp = false;
  byte[] signed = aescsp.SignData(requestBytes, "SHA256");
  
  // For testing purposes - testing the signature
  bool isValid = aescsp.VerifyData(requestBytes, "SHA256", signed);
  string signatureValue = null;
  
  // Deflate the signature string
  using (var output = new MemoryStream())
  {
      using (var zip = new DeflateStream(output, CompressionMode.Compress))
      {
          zip.Write(signed, 0, signed.Length);
      }
      var base64 = Convert.ToBase64String(output.ToArray());
      var urlEncode = HttpUtility.UrlEncode(base64);
      signatureValue = urlEncode;
  }    
  </code></pre>
  
  <p>And still, I see that the validation fails, can some one help me to see why?</p>