SSL error conencting to API

Hi,

I am attempting to use createsend-dotnet and version 3 of the API to sign people up for a newsletter subscription when  they register for my site.

When I test the code locally (Windows 7 dev machine) everything works fine but as soon as I deploy to a staging server running Windows Server 2012 I get an SSL error in the Event Viewer:

"A fatal alert was received from the remote endpoint. The TLS protocol defined fatal alert code is 40."

This is the .NET exception thrown:

Exception: System.Net.WebException: The request was aborted: Could not create SSL/TLS secure channel. at createsend_dotnet.HttpHelper.MakeRequest[T,U,EX](String method, AuthenticationDetails auth, String path, NameValueCollection queryArguments, T payload, String baseUri, String contentType) at createsend_dotnet.HttpHelper.MakeRequest[T,U,EX](String method, AuthenticationDetails auth, String path, NameValueCollection queryArguments, T payload) at createsend_dotnet.HttpHelper.Post[T,U,EX](AuthenticationDetails auth, String path, NameValueCollection queryArguments, T payload) at createsend_dotnet.CreateSendBase.HttpPost[T,U,EX](String path, NameValueCollection queryArguments, T payload) at createsend_dotnet.CreateSendBase.HttpPost[T,U](String path, NameValueCollection queryArguments, T payload) at createsend_dotnet.Subscriber.Add(String emailAddress, String name, List`1 customFields, Boolean resubscribe, Boolean restartSubscriptionBasedAutoresponders) at createsend_dotnet.Subscriber.Add(String emailAddress, String name, List`1 customFields, Boolean resubscribe)



Anyone have any ideas as to why this might happen on Windows Server 2012?

DaveGreasley, 2 years ago

I have enabled .NET tracing on the server and here is what happens:


System.Net Information: 0 : [6480] SecureChannel#15754142::.ctor(hostname=api.createsend.com, #clientCertificates=0, encryptionPolicy=RequireEncryption)
System.Net Information: 0 : [6480] SecureChannel#15754142 - Left with 0 client certificates to choose from.
System.Net Information: 0 : [6480] Using the cached credential handle.
System.Net Information: 0 : [6480] InitializeSecurityContext(credential = System.Net.SafeFreeCredential_SECURITY, context = (null), targetName = api.createsend.com, inFlags = ReplayDetect, SequenceDetect, Confidentiality, AllocateMemory, InitManualCredValidation)
System.Net Information: 0 : [6480] InitializeSecurityContext(In-Buffer length=0, Out-Buffer length=58, returned code=ContinueNeeded).
System.Net.Sockets Verbose: 0 : [6480] Socket#52449292::Send()
System.Net.Sockets Verbose: 0 : [6480] Data from Socket#52449292::Send
System.Net.Sockets Verbose: 0 : [6480] 00000000 : 16 03 00 00 35 01 00 00-31 03 00 54 25 4E 86 A9 : ....5...1..T%N..
System.Net.Sockets Verbose: 0 : [6480] 00000010 : D6 A0 DA FA A8 BE B9 CE-3C 66 FC D0 17 0C D7 3C : ........<f.....<
System.Net.Sockets Verbose: 0 : [6480] 00000020 : DB 17 4A 6C 1C BE FC 2B-F6 A6 6B 00 00 0A 00 05 : ..Jl...+..k.....
System.Net.Sockets Verbose: 0 : [6480] 00000030 : 00 0A 00 13 00 04 00 FF-01 00                   : ..........
System.Net.Sockets Verbose: 0 : [6480] Exiting Socket#52449292::Send()     -> Int32#58
System.Net.Sockets Verbose: 0 : [6480] Socket#52449292::Receive()
System.Net.Sockets Verbose: 0 : [6480] Data from Socket#52449292::Receive
System.Net.Sockets Verbose: 0 : [6480] 00000000 : 15 03 00 00 02                                  : .....
System.Net.Sockets Verbose: 0 : [6480] Exiting Socket#52449292::Receive()     -> Int32#5
System.Net.Sockets Verbose: 0 : [6480] Socket#52449292::Receive()
System.Net.Sockets Verbose: 0 : [6480] Data from Socket#52449292::Receive
System.Net.Sockets Verbose: 0 : [6480] 00000005 : 02 28                                           : .(
System.Net.Sockets Verbose: 0 : [6480] Exiting Socket#52449292::Receive()     -> Int32#2
System.Net Information: 0 : [6480] InitializeSecurityContext(credential = System.Net.SafeFreeCredential_SECURITY, context = 7609682510:ab54b8ee20, targetName = api.createsend.com, inFlags = ReplayDetect, SequenceDetect, Confidentiality, AllocateMemory, InitManualCredValidation)
System.Net Information: 0 : [6480] InitializeSecurityContext(In-Buffers count=2, Out-Buffer length=0, returned code=IllegalMessage).
System.Net.Sockets Verbose: 0 : [6480] Socket#52449292::Dispose()
System.Net Error: 0 : [6480] Exception in HttpWebRequest#20582959:: - The request was aborted: Could not create SSL/TLS secure channel..
System.Net Error: 0 : [6480] Exception in HttpWebRequest#20582959::GetResponse - The request was aborted: Could not create SSL/TLS secure channel..

DaveGreasley, 2 years ago

OK I have fixed the issue finally!

If anyone else has this issue again the following seems to fix it:

                ServicePointManager.Expect100Continue = true;
                ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls;

before any call to the campaign monitor API.

Join 200,000 companies around the world that use Campaign Monitor to run email marketing campaigns that deliver results for their business.

Get started for free
1-888-533-8098