twilio`requestValidator`投掷' system.nullReferenceException'
我将.NET 4.5 Web API用作Twilio SMS接收的Webhook。根据Twilio为安全目的建议的,我正在使用requestValidator
Twilio库的类来验证请求,然后再处理收到的SMS。 第一步是在使用该类的实例之前创建一个实例来验证传入请求:
var requestValidator = new Twilio.Security.RequestValidator(authToken);
var isTwilio = requestValidator.Validate(requestUrl, parameters, signature);
问题是在第一个指令上发生的,该请求正在实例化request> requestValidator
类并抛出以下例外:
'requestValidator._hmac.Hash' threw an exception of type 'System.NullReferenceException'
尽管例外,但创建了实例,但是验证操作(第二个指令)一直返回false。我正在使用最新版本的Twilio,并尝试将应用程序迁移到.NET 4.8,并确保启用并采用TLS1.2。几周前,同样的代码工作正常,突然停止工作。我尝试在新创建的.NET 5控制台应用程序中创建requestValidator
类的实例,并且可以正常工作,但是在针对.NET 4.5和的应用程序中抛出nullreferenceException
4.8。
I am using .NET 4.5 Web API as webhook for Twilio SMS reception. As Twilio recommended for security purposes, I am using the RequestValidator
class of the Twilio library to validate the request before handling the SMS received.
The first step is to create an instance of the class before using it to validate the incoming request:
var requestValidator = new Twilio.Security.RequestValidator(authToken);
var isTwilio = requestValidator.Validate(requestUrl, parameters, signature);
The issue is happening on the first instruction, which is instantiating the RequestValidator
class and throwing the following exception:
'requestValidator._hmac.Hash' threw an exception of type 'System.NullReferenceException'
Despite the exception, the instance is created but the validation operation (second instruction) keeps returning false. I am using the latest version of Twilio , and tried migrating the app to .NET 4.8, and made sure the TLS1.2 is enabled and adopted. The same code was working just fine a couple of weeks ago , and stopped working all of the sudden. I tried creating an instance of the RequestValidator
class in a newly created .NET 5 console app and it's working fine , but throwing the NullReferenceException
in apps that are targeting .NET 4.5 and 4.8.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论