OpenEdge 11.3.1: Changing security protocol types on C# Serv

Posted by 302218 on 16-Sep-2016 07:46

I need to add TLS 1.2 to the C# ServicePointManager:SecurityProtocol property.

This is the c# code looks rather simple:

ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;

But I need to do from the ABL. How would I translate this in ABL code?

Maybe I don't see the obvious but I can only set the property to exactly one value:

 assign ServicePointManager:SecurityProtocol = SecurityProtocolType:Tls11.



Thanks in Advance and Best Regards, Richard.

Posted by Peter Judge on 16-Sep-2016 08:08

Which version of OE? In 11.6 the AND and OR keywords are overloaded to be bitwise operators for enums (as those are).
 
Before that, you have to use the Progress.Util.EnumHelper class.
 

All Replies

Posted by Peter Judge on 16-Sep-2016 08:08

Which version of OE? In 11.6 the AND and OR keywords are overloaded to be bitwise operators for enums (as those are).
 
Before that, you have to use the Progress.Util.EnumHelper class.

Posted by 302218 on 16-Sep-2016 08:14

Thanks for your swift reply. We are running on 11.3.1 and are planning to upgrade to the newest version of OpenEdge (11.6?) Q2 next year.

Posted by tbergman on 16-Sep-2016 09:26

Something like this should work.
 
USING System.Net.*.
ServicePointManager:SecurityProtocol = CAST(Progress.Util.EnumHelper:Or(SecurityProtocolType:Tls12,SecurityProtocolType:Tls11),SecurityProtocolType).
 

Posted by 302218 on 19-Sep-2016 04:03

Thanks to all that have answered. This is the code I've come up with and works without a fuzz:

define variable enumHelper1       as class System.Enum        no-undo.
define variable enumHelper2       as class System.Enum        no-undo.

assign enumHelper1 = Progress.Util.EnumHelper:or ( SecurityProtocolType:Tls, SecurityProtocolType:Tls11 ).

assign enumHelper2 = Progress.Util.EnumHelper:or ( cast ( enumHelper1, SecurityProtocolType ), SecurityProtocolType:Tls12 ).

assign ServicePointManager:SecurityProtocol = cast ( enumHelper2, SecurityProtocolType ).

Of course this works only with .NET 4.5 ( TLS 1.2 support ) ...

Thanks!

This thread is closed