The value ServicePointManager’s of SecurityProtocol property is
ServicePointManager.SecurityProtocol == Ssl3 | Tls /* == Default == 0xF0 */
I don’t want to use explicitly typed protocols for the SecurityProtocol property. Instead, I want the default to be initialized to SystemDefault (0x00).
Additionally, if I explicitly change the value:
ServicePointManager.SecurityProtocol = SecurityProtocolType.SystemDefault;
an exception occurs when I try to communicate:
WebException Status: ReceiveFailure (The underlying connection was
closed: An unexpected error occured on a receive)-> ArgumentException (The specified value is no valid in the ‘SslProtocolType’ enumeration. Parameter name> sslProtocolType)
The solution configuration is as follows:
- (A) Executable EXE project: C++ native application without CLR
support (Common Language Runtime Support: No Common Language Runtime
Support) - (B) DLL project: C++/CLI library with support for managed
code (Common Language Runtime Support: .NET Framework Runtime Support
/clr), which targets .NET Target Framework Version: v4.8.
The initialization of the ServicePointManager.SecurityProtocol
property value probably has something to do with the AppDomain.CurrentDomain.SetupInformation.TargetFrameworkName
value.
The value of TargetFrameworkName is null
even though the assembly (B) has a TargetFrameworkAttribute specified with a value of v4.8. The application domain is internally initialized according to the result of Assembly.GetEntryAssembly
, which in this case returns null
for image (A) (image A is not a managed assembly).