you don't give enough information. common causes are:
- the called site is using a self signed certificate
- the called site requires a higher TSL version then the caller supports
- the called site requires a client certificate
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I am trying to get a fed ex shipping price from a website and this error comes up
System error '80131509'
The request was aborted: Could not create SSL/TLS secure channel.
/webmain.asp, line 12670
How do I fix it?
you don't give enough information. common causes are:
Hi,
It seems that this is a SSL/TLS problem when making HTTPS requests to external APIs like FedEx.
The probable causes could be:
1. TLS Version Issues
// Add this before making any HTTPS requests
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls13;
2. Certificate Validation Problems
// Only for testing - NOT for production
ServicePointManager.ServerCertificateValidationCallback =
(sender, certificate, chain, sslPolicyErrors) => true;
3. Windows/Server Configuration
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Client] "DisabledByDefault"=dword:00000000 "Enabled"=dword:00000001
4. FedEx API Specific Issues
Here's how you can attempt to troubleshoot this problem:
Step 1: Test Basic Connectivity
try
{
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
using (var client = new WebClient())
{
string result = client.DownloadString("https://www.fedex.com");
Response.Write("Connection successful");
}
}
catch (Exception ex)
{
Response.Write($"Error: {ex.Message}");
}
Step 2: Check TLS Configuration
Step 3: Update Your Code (Modern HttpClient approach)
// Modern approach using HttpClient
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls13;
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Add("Content-Type", "application/xml");
try
{
var content = new StringContent(xmlRequest, Encoding.UTF8, "application/xml");
var response = await client.PostAsync("https://fedex-api-endpoint", content);
if (response.IsSuccessStatusCode)
{
string result = await response.Content.ReadAsStringAsync();
// Process result
}
}
catch (HttpRequestException ex)
{
// Handle SSL/TLS errors
Response.Write($"Request error: {ex.Message}");
}
}
Step 4: Alternative with WebRequest
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
try
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://fedex-api-endpoint");
request.Method = "POST";
request.ContentType = "application/xml";
using (StreamWriter writer = new StreamWriter(request.GetRequestStream()))
{
writer.Write(xmlRequest);
}
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
using (StreamReader reader = new StreamReader(response.GetResponseStream()))
{
string result = reader.ReadToEnd();
// Process result
}
}
catch (WebException ex)
{
Response.Write($"Web exception: {ex.Message}");
}
Step 5: Check Server Environment
Step 6: Implement Proper Error Handling
try
{
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
// Your FedEx API call here
}
catch (WebException ex)
{
if (ex.Status == WebExceptionStatus.SecureChannelFailure)
{
Response.Write("SSL/TLS Error: " + ex.Message);
// Log additional details
}
}
catch (Exception ex)
{
Response.Write($"General error: {ex.Message}");
}
Quick Fixes to Try
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
in Application_Start()
or before API callsHope this helps