Dynamic certificate validation when calling Web services

There are situations when you’ll want to call Web services from C/AL, and those Web services might be protected by certificate that your local machine cannot validate directly. Web service might be secured with a self-signed certificate, or by a certificate obtained from an authority that is not globally trusted.

In all those situations, you might need to have a facility to validate certificates yourself. That’s something that’s at the fingertips of all C# developers through the ServerCertificateValidationCallback delegate. However, in C/AL, delegates are unfortunately not (yet) supported.

A friend of mine had this specific problem today, so I remembered that a short while ago I made a “how do I” video on this specific topic. Thanks, Mathias, for giving me a prod, and reminding me of a quick blog topic.

Here’s the link: https://youtu.be/NW_ZiW6J790


Vjeko has been writing code for living since 1995, and he has shared his knowledge and experience in presentations, articles, blogs, and elsewhere since 2002. Hopelessly curious, passionate about technology, avid language learner no matter human or computer.

This Post Has 10 Comments

  1. Emilia Nguyen

    Thank you so much for this post. It saves my day!

  2. allmnt

    somehow would be better to see variables.

    at least for this one

    certificate := Certificate.X509Certificate(MemoryStream)

    1. Vjeko

      You can see the variable type right in the video where this line of code you put here is presented. The Certificate variable is declared as a parameter to the method.

  3. Matt Keyes

    A download link for your VS project would be helpful here

  4. Tim Whitley

    Vjeko, how can this approach be applied to FtpWebRequest?

    That class does not have a ServerCertificateValidationCallback property.

    1. Vjeko

      Sorry, this is .NET and C/AL, and I am not doing that stuff anymore so I can’t give you a solution. However, as a hint – you could wrap your FtpWebRequest into another class that you then talk to directly.

  5. Lokesh

    Hi Vjeko,

    The video not visible to me it shows private video could you please provide video link it can help me lot since am facing the same issue

    1. Vjeko

      Unfortunately, this is Microsoft’s video, and an old one at that. Apparently, they’ve either taken it offline, or made it private. Nothing I can do about it.

  6. Lokesh

    Hi Vjeko,

    Thanks for this post unfortunately the vide not accessible kindly share me the video to my email youmailtolokesh@gmail.com
    this will help me lot.

    Lokesh D

    1. Vjeko

      Sorry, I can’t share this video. I’ve made it, but for Microsoft, so I don’t own it. If they took it offline, then it’s offline, sorry.

Leave a Reply