"The request was aborted: Could not create SSL/TLS secure channel" when calling an API from an API

I’m connection to a SS Api using the SS JsonServiceClient

when I try to connect with:

    public IServiceClient CreateAndAuthenticate()
        var client = new JsonServiceClient(_settings.Url);

        client.Post(new Authenticate
            UserName = _settings.UserName,
            Password = _settings.Password

        return client;

I get an exception on the client.Post() line as:

System.Net.WebException: The request was aborted: Could not create SSL/TLS secure channel.
   at System.Net.HttpWebRequest.GetResponse()
   at System.Net.HttpWebRequest.GetResponse()
   at ServiceStack.ServiceClientBase.Send[TResponse](String httpMethod, String relativeOrAbsoluteUrl, Object request)
   at Mitivo.Services.Helpers.ServiceClientFactory.CreateAndAuthenticate() in C:\TeamCity\buildAgent\work\3e85dcb253d61638\code\Mitivo.Services\Helpers\IServiceClientFactory.cs:line 23
   at Mitivo.Services.Helpers.GkoApiConsumer.GetProductsDetails(Int32 portalId) in C:\TeamCity\buildAgent\work\3e85dcb253d61638\code\Mitivo.Services\Helpers\GkoApiConsumer.cs:line 83
   at Mitivo.Services.Helpers.ProductDataUpdater.Update(RedeemSetting redeemSettings) in C:\TeamCity\buildAgent\work\3e85dcb253d61638\code\Mitivo.Services\Helpers\IProductDataUpdater.cs:line 32
   at Mitivo.Services.Services.TaskRunnerService.RefreshProducts(String companyGuid) in C:\TeamCity\buildAgent\work\3e85dcb253d61638\code\Mitivo.Services\Services\TaskRunnerService.cs:line 147

my url is a https and I start the call in a https environment.

This is an API route that is calling another API.

Is there a simple way to avoid this? I’m sure I’m missing something obviously :frowning:

API used to make the request: https://api.mitivo.com
API used to run the task: https://salesapi.gavekortet.dk

Not sure why, but both those addresses are redirecting to HTTP which I’d guess is what is causing the issue.

Take a look at whatever is handling routing on those domains (load balancer, reverse proxy etc) as that is probably the culprit.

1 Like