#regionprivate static bool Validateservercertificate resolve error "The underlying connection has been closed: failed to establish a trust relationship for the SSL/TLS secure channel. "/// <summary> ///Resolve Error "The underlying connection has been closed: failed to establish a trust relationship for the SSL/TLS secure channel. " /// </summary> /// <param name= "Sender" ></param> /// <param name= "certificate" ></param> /// <param name= "Chain" ></param> /// <param name= "sslpolicyerrors" ></param> /// <returns></returns> Private Static BOOLValidateservercertificate (Objectsender, X509Certificate certificate, X509chain chain, sslpolicyerrors sslpolicyerrors) { return true; } #endregion .............................. .............................. ................. ............ Servicepointmanager.servercertificatevalidationcallback=validateservercertificate; byte[] Responsearray = webclient.uploadvalues (URL, postvalues);
Before the request, add
Servicepointmanager.servercertificatevalidationcallback = validateservercertificate;
The underlying connection has been closed: failed to establish a trust relationship for the SSL/TLS secure channel