| | |
| | | using System.IO; |
| | | using System.Linq; |
| | | using System.Net; |
| | | using System.Net.Security; |
| | | using System.Reflection; |
| | | using System.Security.Cryptography.X509Certificates; |
| | | using System.Text; |
| | | using System.Xml; |
| | | using Newtonsoft.Json; |
| | |
| | | { |
| | | public class HttpHelper |
| | | { |
| | | private static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors) |
| | | { |
| | | return true; //如果不希望验证证书有效性,直接返回 true |
| | | } |
| | | |
| | | private static HttpWebRequest GetHttpWebRequest(string url, Dictionary<string, string> headerDic, string method) |
| | | { |
| | | HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest; |
| | |
| | | } |
| | | try |
| | | { |
| | | if (url.Contains("https")) |
| | | { |
| | | ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult); |
| | | } |
| | | var requestData = GetResponseString(request); |
| | | LogFile.SaveLogToFile($"{logStr}反馈:( {requestData} ),", logStr2); |
| | | return requestData; |
| | |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | } |