Skip to main content

Notifications

Microsoft Dynamics NAV (Archived)

Using NAV CU1290 SOAP Web Service Request Mgt. to connect with a server using a self-signed certificate - HttpWebRequest.GetResponse Error "The remote certificate is invalid according to the validation procedure."

Posted on by

Working in NAV 2017, I'm trying to use CU1290 SOAP Web Service Request Mgt. to send a request and get a response from a server using a self-signed certificate.  I've installed the certificate on the server with certlm in Trusted Root Certificate Authorities.  I can make the request through my browser (which does still show a certificate error) but calling through the NAV library and eventually DotNet's System.Het.HttpWebRequest.GetResponse, I get the failure message "The remote certificate is invalid according to the validation procedure."

I see from the DotNet forums that you can override the certificate validation logic by installing a callback for ServicePointManager.ServerCertificateValidationCallback  (https://stackoverflow.com/questions/1189897/net-programming-what-to-validate-on-an-ssl-self-signed-certificate).

The problem is, I can't figure out how to load a callback from within C/AL.  Is this possible?  Is there another way to disable the certificate test, ideally on a call-by-call basis?  Should I just do all this in DotNet and give up on CU1290?

*This post is locked for comments

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Using NAV CU1290 SOAP Web Service Request Mgt. to connect with a server using a self-signed certificate - HttpWebRequest.GetResponse Error "The remote certificate is invalid according to the validation procedure."

    Hi,

    Did you solve your problem?

  • Verified answer
    keoma Profile Picture
    keoma 32,675 on at
    RE: Using NAV CU1290 SOAP Web Service Request Mgt. to connect with a server using a self-signed certificate - HttpWebRequest.GetResponse Error "The remote certificate is invalid according to the validation procedure."

    correct, DisableHttpsCheck is for using http.

  • RE: Using NAV CU1290 SOAP Web Service Request Mgt. to connect with a server using a self-signed certificate - HttpWebRequest.GetResponse Error "The remote certificate is invalid according to the validation procedure."

    Thanks for your prompt response, Stefano.  I did have DisableHttpsCheck, but that didn't help.  I believe that DisableHttpsCheck is intended to permit use of http (instead of requiring https.)  My problem is that the target services was https using a self-signed certificate.

  • Verified answer
    keoma Profile Picture
    keoma 32,675 on at
    RE: Using NAV CU1290 SOAP Web Service Request Mgt. to connect with a server using a self-signed certificate - HttpWebRequest.GetResponse Error "The remote certificate is invalid according to the validation procedure."

    that won't work using cu 1290 and .net class httpwebrequest.

    as you found also out, what you need for certificates like that is following c# code in nav:

    System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate(Object obj, X509Certificate X509certificate, X509Chain chain, System.Net.Security.SslPolicyErrors errors)

           {

               return true;

           };

    that's not possible in nav.

    i had that issue, developed then a .net lib for the complete web service call in c#.

  • Stefano Demiliani Profile Picture
    Stefano Demiliani 37,162 Most Valuable Professional on at
    RE: Using NAV CU1290 SOAP Web Service Request Mgt. to connect with a server using a self-signed certificate - HttpWebRequest.GetResponse Error "The remote certificate is invalid according to the validation procedure."

    Try DisableHttpsCheck:

    WebServReqMgt.SetGlobals(ReqBodyInStream,Url,Username,Password);

    WebServReqMgt.DisableHttpsCheck;

    WebServReqMgt.RUN;

    // get the response

    WebServReqMgt.GetResponseContent(RespBodyInStream);

    ResponseXmlDoc := ResponseXmlDoc.XmlDocument;

    ResponseXmlDoc.Load(RespBodyInStream);

    MESSAGE(ResponseXmlDoc.InnerXml);

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans