using System.Security.Cryptography.X509Certificates;
public static void Main()
string post_data = "foo=bar&baz=oof";
string uri = "https://google.com";
HttpWebRequest request = (HttpWebRequest)
WebRequest.Create(uri); request.KeepAlive = false;
request.ProtocolVersion = HttpVersion.Version10;
byte[] postBytes = Encoding.ASCII.GetBytes(post_data);
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = postBytes.Length;
Stream requestStream = request.GetRequestStream();
requestStream.Write(postBytes, 0, postBytes.Length);
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Console.WriteLine(new StreamReader(response.GetResponseStream()).ReadToEnd());
Console.WriteLine(response.StatusCode);
public class MyPolicy : ICertificatePolicy
public bool CheckValidationResult(ServicePoint srvPoint,
X509Certificate certificate, WebRequest request,