C# Translate to ABL - Ignoring bad SSL certificates

Posted by tbergman on 27-Apr-2016 06:12

I'm pretty sure this can't be done directly in the ABL but wanted to run it past the experts to confirm. I'd be very happy to be wrong.

ServicePointManager.ServerCertificateValidationCallback = MyCertHandler;

static bool MyCertHandler(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors error)

{

return true;

}

All Replies

Posted by Mike Fechner on 27-Apr-2016 06:21

Unfortunately you are correct. The ABL does not support implementing .NET delegate types, which is what the ServerCertificateValidationCallback property is.

msdn.microsoft.com/.../system.net.security.remotecertificatevalidationcallback(v=vs.110).aspx

But you just have to create a .NET class for the delegate. The rest of the code might return ABL. Typically, when I need to deal with synchronously called delegates, I write a C# class that implements the delegate and raises an event. That way I can implement an event handler in the ABL and keep most of the actual logic in ABL.

Posted by marian.edu on 27-Apr-2016 06:22

sadly you’re right, callbacks (delegates) are not supported so you’ll need to build some kind of wrapper in .net for that :(

 
Marian Edu

Acorn IT 
+40 740 036 212

Posted by tbergman on 27-Apr-2016 06:32

Thanks to everyone who responded for the confirmation. Easy enough to do in C#. In this case, I don’t even need anything back, I just need to allow the .Net WebClient or HttpClient to ignore certificate errors.
Every once in a while one of our internal sites with a certificate needs to be accessed using its IP address, which, of course, is not the name on the certificate they’re using.
 
Tom
 

Posted by rvkanten on 29-Jul-2016 09:32

Mike, what to do when I want to perform a HTTPS call in an AppServer agent? Documentation states: "OpenEdge does not support the handling of .NET object events in non-GUI ABL sessions, such as a character-mode client or AppServer agent.".

Roger van Kanten

Posted by bronco on 29-Jul-2016 09:46

Well Roger, that depends on the OpenEdge version you're running (still 10.2B?). The restriction on running the non-UI .NET classes have been lifted for a while (somewhere in 11.x, don't know which one exactly).

Posted by Peter Judge on 29-Jul-2016 09:48

10.2B08 IIRC

Posted by bronco on 29-Jul-2016 10:01

Ah, they retro fitted it to 10.2B? Much to my delight I don't have to work with that version anymore :-)

Posted by rvkanten on 01-Aug-2016 04:14

We're using 11.5.0 but the quote about the .NET object events is from the 11.6 documentation, page 62 of "GUI for .NET Programming".

Posted by Mike Fechner on 01-Aug-2016 04:18

To my experience that refers to UI events. You can certainly subscribe to a class event and the event handler will execute when the event is raised. .NET Events are just synchronous (potentially multiple) call backs.

Posted by rvkanten on 01-Aug-2016 04:25

Thanks Mike.

Posted by Laura Stern on 01-Aug-2016 08:31

Yes, that quote in the 11.6 doc is no longer correct.  I will get log a bug to get it removed.

This thread is closed