This indicates a problem with establishing a HTTPS connection. Based on the stacktrace provided, it looks like you're targeting an older version .NET Framework that uses the older System.Net.HttpWebRequest type for HTTP.
My suspicion is that the version of .NET Framework is not configured to support the version of TLS that Elasticsearch Service on Cloud is using; If I recall correctly, the service uses TLS 1.2, which older .NET Framework versions may not be configured by default to support.
A couple of different options that I would recommend
-
Update to a newer .NET Framework version that supports TLS 1.2 by default
-
Configure
ServicePointManager.SecurityProtocolto use TLS 1.2. If patches have been applied that default the OS to use TLS 1.2, then settingServicePointManager.SecurityProtocoltoSecurityProtocolType.SystemDefaultwill work. Otherwise, it can be set toSecurityProtocolType.Tls12or the int value3072ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072;Bear in mind that changing this property affects TLS for all HTTPS connections from the AppDomain.