c# - The remote certificate is invalid according to the validation procedure -


i want call service can see :

public string servicehostname = "https://122.333.ir/inquiryservice.svc";         public inquiryservice()         {             //clientrequest = new webclient();             ms = new memorystream();         }          public inquiryview inquiry(string plaque)         {             string result = "";             using (webclient clientrequest = new webclient())             {                 clientrequest.headers["content-type"] = "application/json";                 clientrequest.encoding = system.text.encoding.utf8;                 networkcredential credential1 = new networkcredential("1", "1");                 clientrequest.credentials = credential1;                 //result = clientrequest.downloadstring(servicehostname + "/" + "2012-12-28" + "/" + "61" + "-" + "921" + "ج" + "25");                  result = clientrequest.downloadstring(servicehostname + "/inquiry/2012-12-28" + "/" + plaque);             }              var javascriptserializer = new javascriptserializer();             return javascriptserializer.deserialize<inquiryview>(result);         } 

but when call service error :

exception information:      exception type: authenticationexception      exception message: remote certificate invalid according validation procedure.    @ system.net.security.sslstate.startsendauthresetsignal(protocoltoken message, asyncprotocolrequest asyncrequest, exception exception) 

my service certificate self sign ,so downloaded cert , add in trusted root certification can see same error :

enter image description here

one option implement callback.

service​point​manager.​server​certificate​validation​callback

this enable more details exact certification failure.

you can @ sslpolicyerrors enum see exact failure reason

public enum sslpolicyerrors {     none                          = 0x0,     remotecertificatenotavailable = 0x1,     remotecertificatenamemismatch = 0x2,     remotecertificatechainerrors  = 0x4 } 

Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -