Exception while trying to connect a server w/o a certificate

goldami1goldami1 Member ✭✭

Hi,

When I debug my app, I get exception on the line of code:
System.Net.ServicePointManager.ServerCertificateValidationCallback = (sender, certificate, chain, sslPolicyErrors) => true;

The exception is:
" Object of type 'System.Func`5[System.Object,System.Security.Cryptography.X509Certificates.X509Certificate,System.Security.Cryptography.X509Certificates.X509Chain,System.Net.Security.SslPolicyErrors,System.Boolean]' cannot be converted to type 'System.Net.Security.RemoteCertificateValidationCallback'. (ArgumentException)] "

Can't fix it in anyway I tried,
please help

Best Answer

Answers

  • AdamMeaneyAdamMeaney USMember ✭✭✭✭✭

    Your line is missing the +=, you just have an =

  • goldami1goldami1 Member ✭✭

    It doesn't change anything. Still not working

  • SYLENDRABABUJRSYLENDRABABUJR USMember ✭✭

    Hi,

    @goldami1,@AdamMeaney

    For me also getting the same Exception at this line

    System.Net.ServicePointManager.ServerCertificateValidationCallback = (sender, certificate, chain, sslPolicyErrors) => true;

    The exception is:
    " Object of type 'System.Func`5[System.Object,System.Security.Cryptography.X509Certificates.X509Certificate,System.Security.Cryptography.X509Certificates.X509Chain,System.Net.Security.SslPolicyErrors,System.Boolean]' cannot be converted to type 'System.Net.Security.RemoteCertificateValidationCallback'. (ArgumentException)] "

    I tried to set it in the MainActivity also but no use.

    If I remove the below line and Setting EnableSsl=true geting the "The authentication or decryption has failed." error.
    System.Net.ServicePointManager.ServerCertificateValidationCallback = (sender, certificate, chain, sslPolicyErrors) => true;

    Please help me...

  • AdamMeaneyAdamMeaney USMember ✭✭✭✭✭

    @SYLENDRABABUJR You have the exact same problem. You wrote

    System.Net.ServicePointManager.ServerCertificateValidationCallback = (sender, certificate, chain, sslPolicyErrors) => true;

    When you want

    System.Net.ServicePointManager.ServerCertificateValidationCallback += (sender, certificate, chain, sslPolicyErrors) => true;

  • SYLENDRABABUJRSYLENDRABABUJR USMember ✭✭

    Hi Adam ,
    Thanks for you reply.I done that but I'm getting the new exception
    "The authentication or decryption has failed"
    You can download the Source code from the below link
    https://t.co/yjHqElCeMD

  • SYLENDRABABUJRSYLENDRABABUJR USMember ✭✭

    Hi Adam ,@AdamMeaney
    Thanks for you reply.I done that but I'm getting the new exception
    "The authentication or decryption has failed"
    You can download the Source code from the below link
    https://t.co/yjHqElCeMD

Sign In or Register to comment.