4

I am using Twilio REST client in Visual Studio 2017. After adding a Studio Flow for a simple SMS autoresponder, I am no longer able to use the Twilio REST API to send a SMS message from my ASP.net app.

The error message is "Upgrade Required"

at Twilio.Clients.TwilioRestClient.ProcessReponse(Reponse response)
at Twilio.Rest.Api.V2010.Account.MessageResource.Create(CreateMessageOptions options, ITwilioRestClient client)
at...

I already tried upgrading the Twilio REST API helper library NuGet package to latest, version 5.28.0.

The error occurs on this basic SMS sending code that used to work.

Dim message = MessageResource.Create(body:=strBody, from:=New Twilio.Types.PhoneNumber(Credentials.TwilioFixityNewNumberFormatted), [to]:=New Twilio.Types.PhoneNumber(strFormattedNumber))
Return message.Sid

There are no error messages or notifications in my Twilio account that something is wrong or needed. Has anyone experienced something like this?

A. Niese
  • 399
  • 3
  • 13
  • It's not clear what exactly you did as to "adding a Studio Flow". If you revert whatever you did, are you then able to send messages again? – Alex Baban Mar 30 '19 at 16:28
  • No, I can't revert. I simply followed the guide in the link. After examining the exception it appears to be API error 20426 and/or 20011. The accompanying documentation says that new TLS 1.2 requirements go in effect for new projects created after 3/28/19. My guess is that adding the Flow made the project "new" and subject to these new requirements that my HTTP client currently cannot handle. https://support.twilio.com/hc/en-us/articles/360007724794-Notice-Twilio-REST-API-s-TLS-and-Cipher-Suite-Security-Changes-for-June-2019 – A. Niese Mar 30 '19 at 17:16

2 Answers2

3

It seems that modifying the Twilio project made it a "new" project subject to TLS 1.2 requirements that were just implemented on 3/28/19. The problem was solved by updating Windows and .NET to the latest updates, and explicitly enabling TLS 1.2 prior to accessing the Twilio REST API:

ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12   'Force TLS 1.2
A. Niese
  • 399
  • 3
  • 13
2

Twilio returns Upgrade Required when you use an old TLS version. Setting the version directly using ServicePointManager.SecurityProtocol does fix it, but it's not a good idea since it'll become outdated when a new TLS version is released. Instead, see Transport Layer Security (TLS) best practices with the .NET Framework for some reasons it may be selecting an older version.

In my case it was due to this line in Web.config:

<httpRuntime targetFramework="4.5" />

Setting it to the actual .NET Framework version I'm using fixed the Twilio error.

Pathoschild
  • 4,636
  • 2
  • 23
  • 25