I'm working on a C# project which runs fine from my development workstation VS2019. The application makes a REST API call to a server which runs a procedure and returns a response. Everything works fine from my workstation. But when I post the project to IIS8 server and run it I get an error Could not create SSL/TLS channel.
The error occurs when I call WebResponse webResponse = request.GetResponse();
I've updated the server to .NET 8.0 . Any help is much appreciated.
//Production Server
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://api.myibservices.com/v1/authenticate");
string authInfo = "XXXXXXXXX:XXXXXXXXX";
request.ContentType = "application/json";
request.Method = "GET";
authInfo = Convert.ToBase64String(Encoding.Default.GetBytes(authInfo));
request.Headers["Authorization"] = "Basic " + authInfo;
WebResponse webResponse = request.GetResponse();
using (StreamReader reader = new StreamReader(webResponse.GetResponseStream()))
{
response = reader.ReadToEnd();
}
In addition the server uses Tls12 which is part of my code at the beginning of the method: ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;