title: C# equivalent of OpenSSL signing
body: <p>I have to sign some data using SHA256, and I have an example created with OpenSSL:</p>
  
  <pre><code>johnd@johns-machine:~/sandboxcerts$ signingString="(request-target): post /oauth2/token
  date: Wed, 11 Apr 2018 15:07:23 GMT
  digest: SHA-256=47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=
  x-ing-reqid: e86bf09b-d772-4528-af83-ba42aa594ac4"
  
  johnd@johns-machine:~/sandboxcerts$ signature=`printf "$signingString" | openssl dgst -sha256 -sign ~/sandboxcerts/example_client_signing.key -passin "pass:changeit" | openssl base64 -A`
  </code></pre>
  
  <p>I am trying to do the same thing in C# like this:</p>
  
  <pre><code>// loading my private key
  X509Certificate2 cert = new X509Certificate2(certPath, certPass);
  RSACryptoServiceProvider key = cert.PrivateKey as RSACryptoServiceProvider;
  
  string signingString = @"(request-target): post /oauth2/token
  date: Wed, 11 Apr 2018 15:07:23 GMT
  digest: SHA - 256 = 47DEQpj8HBSa +/ TImW + 5JCeuQeRkm5NMpJWZG3hSuFU =
          x - ing - reqid: e86bf09b - d772 - 4528 - af83 - ba42aa594ac4";
  
  signingString = signingString.Replace("\n", string.Empty);
  signingString = signingString.Replace("\r", string.Empty);
  signingString = signingString.Replace("\t", string.Empty);
  
  byte[] sig = privKey.SignData(Encoding.ASCII.GetBytes(signingString), CryptoConfig.MapNameToOID("SHA256"));
  Console.WriteLine(Convert.ToBase64String(sig));
  </code></pre>
  
  <p>but I am not getting the same result. I tried different encodings and removing or not removing new lines, tabs etc. but I still didn't get it right.</p>