分润宝,专注各种模式分润系统开发!分润结算系统开发!
全国服务热线0592-5519259 在线咨询 微信咨询

分润宝客服

分润宝客服

在线客服

常见问题 > 技术文档

POST提交出现"根据验证过程,远程证书无效。"

 public static bool ValidateServerCertificate(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
        {
            //if (sslPolicyErrors == SslPolicyErrors.None)
            return true;
            //else
            //{
            //    return false;
            //}
        }
        public string PostData(string apiUrl, string postString)
        {
            byte[] postData = Encoding.UTF8.GetBytes(postString);
            WebClient webClient = new WebClient();
            //webClient.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
            webClient.Headers.Add("Content-Type", "application/json;charset=UTF-8");
            var timestamp = ((long)TimeUtil.ToMillisecondsTimestamp(DateTime.Now)).ToString();
            //webClient.Headers.Add("X-Auth-OEM", oem);
            webClient.Headers.Add("ContentLength", postData.Length.ToString());
            ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(ValidateServerCertificate);
            byte[] responseData = webClient.UploadData(apiUrl, "POST", postData); //得到返回字符 
            StringBuilder resultBuilder = new StringBuilder();
            resultBuilder.Append(Encoding.UTF8.GetString(responseData));
            string resultString = resultBuilder.ToString().Replace('\\', ' ');
            return resultString;
        }

如果没有解决您的问题,请立即联系客服

声明:文章"POST提交出现"根据验证过程,远程证书无效。""为分润宝原创文章,转载请注明出处,谢谢合作!

分润宝公众号

客服

微信客服

置顶