Hi, I am developing an sms receiving app in
mvc.net using plivo.
I am unable to validate plivo signature in
mvc.net. whenever i try to validate request using plivo .net helper library "XPlivoSignature.Verify()" it always return false. My code is given below please let me know if I am doing anything wrong.
Any help will be highly appreciated
[HttpPost]
public ActionResult Receive(string From, string To, string Type, string Text, string MessageUUID)
{
// here is the problem it always return false
if (ValidatePlivoRequest(Request))
{
// do some stuff i.e store message in db
}
}
private bool ValidatePlivoRequest(HttpRequestBase request)
{
bool validRequest = false;
string actualsignature = request.Headers["X-Plivo-Signature"];
String auth_token = ConnectionStringHelper.PlivoAuthenticationToken;
Dictionary<string, string> parameters = new Dictionary<string, string>();
if (Request.QueryString != null)
{
foreach (String key in Request.QueryString.Keys)
{
String value = Request.QueryString[key];
parameters.Add(key, value);
}
}
//String url = request.Url.SiteBase + request.Url.Path;
string url = ConnectionStringHelper.PlivoSmsReceiveUrlForValidation;
if (Request.Form != null)
{
foreach (String key in Request.Form.Keys)
{
String value = Request.Form[key];
parameters.Add(key, value);
}
}
// here is the problem it always return false
validRequest = XPlivoSignature.Verify(url, parameters, actualsignature, auth_token);
return validRequest;
}