Could not create SSL/TLS secure channel

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

  1. Update to a newer .NET Framework version that supports TLS 1.2 by default

  2. Configure ServicePointManager.SecurityProtocol to use TLS 1.2. If patches have been applied that default the OS to use TLS 1.2, then setting ServicePointManager.SecurityProtocol to SecurityProtocolType.SystemDefault will work. Otherwise, it can be set to SecurityProtocolType.Tls12 or the int value 3072

    ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072;
    

    Bear in mind that changing this property affects TLS for all HTTPS connections from the AppDomain.

1 Like