Question

Ringcentral subscription NotificationEvent Decrypt Method issue

  • 16 January 2020
  • 1 reply
  • 145 views

We are impelementing Ringcentral Subscription functionality.

For that We are using code from github url:

https://github.com/ringcentral/ringcentral-csharp/tree/master/RingCentral/Subscription

We are facing issue in class SubscriptionService.cs:

Below is method where we actually facing issue:

private void OnSubscribe(string result)

{

var message = JsonConvert.DeserializeObject<string[]>(result)[0];

NotificationEvent?.Invoke(this, new SubscriptionEventArgs(Decrypt(message)));

}


We dont know what happen in Decrypt(message) function because Debug not going through that code i.e Decrypt(message). message parameter showing encrypted key


Below is Decrypt method:


private object Decrypt(string dataString)

{

var key = Convert.FromBase64String(subscriptionInfo.DeliveryMode.EncryptionKey);

var keyParameter = ParameterUtilities.CreateKeyParameter("AES", key);

var cipher = CipherUtilities.GetCipher("AES/ECB/PKCS7Padding");

cipher.Init(false, keyParameter);


var data = Convert.FromBase64String(dataString);

var memoryStream = new MemoryStream(data, false);

var cipherStream = new CipherStream(memoryStream, cipher, null);


var bufferSize = 1024;

var buffer = new byte[bufferSize];

var length = 0;

var resultStream = new MemoryStream();

while ((length = cipherStream.Read(buffer, 0, bufferSize)) > 0)

{

resultStream.Write(buffer, 0, length);

}

var resultBytes = resultStream.ToArray();

var result = Encoding.UTF8.GetString(resultBytes, 0, resultBytes.Length);

return JsonConvert.DeserializeObject(result);

}




Please guide us...!!

Thank you..!!



1 reply

Userlevel 1

The c-sharp SDK has been deprecated for years and it was mentioned on the repo README file.

Can you port your app to use the latest .Net SDK then let me know if you are still facing the problem.

Reply