AnsweredAssumed Answered

The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.

Question asked by Ramadevi chinthala on Oct 17, 2018
Latest reply on Oct 26, 2018 by Ramadevi chinthala

Hi,

 I am trying to call canvas API to get the course information using ASP.NET.In my local system, I don't have any issues to retrieve the course information by calling canvas API. After deploying the web service in the production server,I am getting the below error "The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.?

 

Do you have any answers how to fix the issue in the production server?

 

Code:

protected static async Task<HttpResponseMessage> httpGET(string baseUrl, string urlCommand, string accessToken)
{
HttpResponseMessage response = null;

try
{

HttpClientHandler handler = new HttpClientHandler();
if (ConfigurationSettings.AppSettings["TestMode"].ToLower() != "yes")
{
handler.Proxy = new WebProxy("ProxyURL:PORTNUMBER");
handler.UseProxy = true;
}

handler.UseDefaultCredentials = true;
_logger.Info("add handler to http client");
using (HttpClient client = new HttpClient(handler, true))
{
client.BaseAddress = new Uri(baseUrl);
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);
_logger.Info(" call api");
// response = await client.GetAsync(urlCommand);
response = client.GetAsync(urlCommand).Result;
_logger.Info("ends call api");
}
}
catch (Exception err)
{
_logger.Error("[EXCEPTION] Failed to execute HTTP GET command: [" + baseUrl + urlCommand + "]", err.InnerException);

}

return response;
}

 

Thanks,

Devi.

Outcomes