question

Pramod Kangare avatar image
Pramod Kangare asked Phong Vu answered

Ringcentral subscription NotificationEvent Decrypt Method issue

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..!!


ringcentral subscription
1 |1000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

1 Answer

·
Phong Vu avatar image
Phong Vu answered

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.

1 |1000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.