csharp-sparkpost
csharp-sparkpost copied to clipboard
TLS upgrade
Might need to add System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls11 | System.Net.SecurityProtocolType.Tls12;
for the system to use the new TLS version
It may be better to set SecurityProtocol on your code than inside SparkPost library. Another solution is to upgrade .NET framework version. Transport Layer Security (TLS) best practices with the .NET Framework
Grrr!!! Thanks Jason for the code, I had to put this above anywhere I was using the SparkPost CSharp nuget package code to send emails, as my emails have been getting lost for almost a week!!!
@aaronclausen I second your Grrrr! If this is required to function, it needs to be handled in the library. Ran into this one today as well on our account.
Third Grrrr!!!!!
Thanks for this @jasonwuonline .
Before, when I called Sparkpost.Client.Transmissions.Send(), I was getting a System.Net.Sockets.SocketException with An existing connection was forcibly closed by the remote host.
Adding the following fixed it and allowed the email to be sent successfully.
System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls11 | System.Net.SecurityProtocolType.Tls12;
... some omitted details which are specific to my code
Inner Exception 2: HttpRequestException: An error occurred while sending the request.
Inner Exception 3: WebException: The underlying connection was closed: An unexpected error occurred on a send.
Inner Exception 4: IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.
Inner Exception 5: SocketException: An existing connection was forcibly closed by the remote host