csharp-sparkpost icon indicating copy to clipboard operation
csharp-sparkpost copied to clipboard

TLS upgrade

Open jasonwuonline opened this issue 7 years ago • 5 comments

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

jasonwuonline avatar Jul 03 '18 01:07 jasonwuonline

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

lichutin avatar Jul 03 '18 07:07 lichutin

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 avatar Jul 27 '18 07:07 aaronclausen

@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.

ohine avatar Jul 31 '18 01:07 ohine

Third Grrrr!!!!!

LatoSoftware avatar Aug 02 '18 00:08 LatoSoftware

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

ta-stott-oe avatar Apr 23 '20 14:04 ta-stott-oe