Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)

Paste

Pasted as C# by Lavrentiy Golovkov ( 17 years ago )
HttpWebRequest request = WebRequest.Create("https://www.domain.zone/path/file.ext") as HttpWebRequest;
                X509Certificate certificate = new X509Certificate(Server.MapPath("~/filename.pfx"), "password", X509KeyStorageFlags.PersistKeySet);
                X509Store store = new X509Store(StoreLocation.CurrentUser);
                store.Open(OpenFlags.MaxAllowed);
                if ( !store.Certificates.Contains(certificate) ) store.Add(new X509Certificate2(certificate));
                store.Close();
                request.ClientCertificates.Add(certificate);
                request.Method = WebRequestMethods.Http.Post;
                request.ContentType = "text/xml";
                request.ContentLength = xmlrequest.Length;
                byte[] bytes = ASCIIEncoding.ASCII.GetBytes("<root></root>");
                Stream stream = request.GetRequestStream();
                stream.Write(bytes, 0, bytes.Length);
                stream.Close();
                HttpWebResponse response = request.GetResponse() as HttpWebResponse;
                StreamReader answer = new StreamReader(response.GetResponseStream());
                XmlDocument xml = new XmlDocument();
                xml.LoadXml(answer.ReadToEnd());
                answer.Close();

 

Revise this Paste

Parent: 9474
Your Name: Code Language: