Code like the following .
[WebMethod]
public string HelloWorld()
{
System.Net.ServicePointManager.CertificatePolicy=n ew CertificateEx();
System.Net.HttpWebRequest
req=(System.Net.HttpWebRequest)System.Net.WebReque st.Create(https://example.
com) ; //this site does not require client certificate
System.Net.HttpWebResponse
res=(System.Net.HttpWebResponse)req.GetResponse();
return new System.IO.StreamReader (res.GetResponseStream()).ReadToEnd() ;
}
public class CertificateEx: System.Net.ICertificatePolicy
{
#region ICertificatePolicy ³ÉÔ±
public bool CheckValidationResult(System.Net.ServicePoint srvPoint,
System.Security.Cryptography.X509Certificates.X509 Certificate certificate,
System.Net.WebRequest request, int certificateProblem)
{
// TODO: Ìí¼Ó CertificateEx.CheckValidationResult ʵÏÖ
return true;
}
#endregion
get the error says:
The underlying connection was closed: Could not establish trust relationship
with remote server.
--
Thank you for your time!