Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix/JSON Serialisation when message decryption failed #202

Merged
merged 2 commits into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions .pubnub.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
name: c-sharp
version: "6.19.4"
version: "6.19.5"
schema: 1
scm: github.com/pubnub/c-sharp
changelog:
- date: 2024-01-17
version: v6.19.5
changes:
- type: bug
text: "Fixes issue of getting exception for custom objects in subscription and history when crypto module is configured."
- date: 2023-11-28
version: v6.19.4
changes:
Expand Down Expand Up @@ -761,7 +766,7 @@ features:
- QUERY-PARAM
supported-platforms:
-
version: Pubnub 'C#' 6.19.4
version: Pubnub 'C#' 6.19.5
platforms:
- Windows 10 and up
- Windows Server 2008 and up
Expand All @@ -771,7 +776,7 @@ supported-platforms:
- .Net Framework 4.5
- .Net Framework 4.6.1+
-
version: PubnubPCL 'C#' 6.19.4
version: PubnubPCL 'C#' 6.19.5
platforms:
- Xamarin.Android
- Xamarin.iOS
Expand All @@ -791,7 +796,7 @@ supported-platforms:
- .Net Core
- .Net 6.0
-
version: PubnubUWP 'C#' 6.19.4
version: PubnubUWP 'C#' 6.19.5
platforms:
- Windows Phone 10
- Universal Windows Apps
Expand All @@ -815,7 +820,7 @@ sdks:
distribution-type: source
distribution-repository: GitHub
package-name: Pubnub
location: https://github.com/pubnub/c-sharp/releases/tag/v6.19.4.0
location: https://github.com/pubnub/c-sharp/releases/tag/v6.19.5.0
requires:
-
name: ".Net"
Expand Down Expand Up @@ -1098,7 +1103,7 @@ sdks:
distribution-type: source
distribution-repository: GitHub
package-name: PubNubPCL
location: https://github.com/pubnub/c-sharp/releases/tag/v6.19.4.0
location: https://github.com/pubnub/c-sharp/releases/tag/v6.19.5.0
requires:
-
name: ".Net Core"
Expand Down Expand Up @@ -1457,7 +1462,7 @@ sdks:
distribution-type: source
distribution-repository: GitHub
package-name: PubnubUWP
location: https://github.com/pubnub/c-sharp/releases/tag/v6.19.4.0
location: https://github.com/pubnub/c-sharp/releases/tag/v6.19.5.0
requires:
-
name: "Universal Windows Platform Development"
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
v6.19.5 - January 17 2024
-----------------------------
- Fixed: fixes issue of getting exception for custom objects in subscription and history when crypto module is configured.

v6.19.4 - November 28 2023
-----------------------------
- Fixed: handle unencrypted message while getting messages with crypto.
Expand Down
4 changes: 2 additions & 2 deletions src/Api/PubnubApi/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
[assembly: AssemblyProduct("Pubnub C# SDK")]
[assembly: AssemblyCopyright("Copyright © 2021")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyVersion("6.19.4.0")]
[assembly: AssemblyFileVersion("6.19.4.0")]
[assembly: AssemblyVersion("6.19.5.0")]
[assembly: AssemblyFileVersion("6.19.5.0")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
Expand Down
4 changes: 2 additions & 2 deletions src/Api/PubnubApi/PubnubApi.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@

<PropertyGroup>
<PackageId>Pubnub</PackageId>
<PackageVersion>6.19.4.0</PackageVersion>
<PackageVersion>6.19.5.0</PackageVersion>
<Title>PubNub C# .NET - Web Data Push API</Title>
<Authors>Pandu Masabathula</Authors>
<Owners>PubNub</Owners>
<PackageLicenseFile>LICENSE.txt</PackageLicenseFile>
<PackageIconUrl>http://pubnub.s3.amazonaws.com/2011/powered-by-pubnub/pubnub-icon-600x600.png</PackageIconUrl>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<RepositoryUrl>https://github.com/pubnub/c-sharp/</RepositoryUrl>
<PackageReleaseNotes>Handle unencrypted message while getting messages with crypto.</PackageReleaseNotes>
<PackageReleaseNotes>Fixes issue of getting exception for custom objects in subscription and history when crypto module is configured.</PackageReleaseNotes>
<PackageTags>Web Data Push Real-time Notifications ESB Message Broadcasting Distributed Computing</PackageTags>
<!--<Summary>PubNub is a Massively Scalable Web Push Service for Web and Mobile Games. This is a cloud-based service for broadcasting messages to thousands of web and mobile clients simultaneously</Summary>-->
<Description>PubNub is a Massively Scalable Web Push Service for Web and Mobile Games. This is a cloud-based service for broadcasting messages to thousands of web and mobile clients simultaneously</Description>
Expand Down
3 changes: 1 addition & 2 deletions src/Api/PubnubApi/PubnubCoreBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -736,8 +736,7 @@ private void ResponseToUserCallback<T>(List<object> result, PNOperationType type
currentConfig.LogVerbosity
);
}
object decodeMessage = jsonLib.DeserializeToObject((decryptMessage == "**DECRYPT ERROR**") ? payload.ToString() : decryptMessage);

object decodeMessage = jsonLib.DeserializeToObject((decryptMessage == "**DECRYPT ERROR**") ? jsonLib.SerializeToJsonString(payload) : decryptMessage);
payloadContainer.Add(decodeMessage);
}
else
Expand Down
16 changes: 6 additions & 10 deletions src/Api/PubnubApi/Security/SecureMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
{
List<object> returnMessage = new List<object>();

if (config.CryptoModule != null || config.CipherKey.Length > 0)

Check warning on line 31 in src/Api/PubnubApi/Security/SecureMessage.cs

View workflow job for this annotation

GitHub Actions / Integration and Unit tests

'PNConfiguration.CipherKey' is obsolete: 'CipherKey is deprecated, please use CryptoModule instead.'

Check warning on line 31 in src/Api/PubnubApi/Security/SecureMessage.cs

View workflow job for this annotation

GitHub Actions / Acceptance tests

'PNConfiguration.CipherKey' is obsolete: 'CipherKey is deprecated, please use CryptoModule instead.'

Check warning on line 31 in src/Api/PubnubApi/Security/SecureMessage.cs

View workflow job for this annotation

GitHub Actions / Publish to NuGet

'PNConfiguration.CipherKey' is obsolete: 'CipherKey is deprecated, please use CryptoModule instead.'
{
config.CryptoModule ??= new CryptoModule(new LegacyCryptor(config.CipherKey, config.UseRandomInitializationVector, pubnubLog), null);

Check warning on line 33 in src/Api/PubnubApi/Security/SecureMessage.cs

View workflow job for this annotation

GitHub Actions / Integration and Unit tests

'PNConfiguration.CipherKey' is obsolete: 'CipherKey is deprecated, please use CryptoModule instead.'

Check warning on line 33 in src/Api/PubnubApi/Security/SecureMessage.cs

View workflow job for this annotation

GitHub Actions / Integration and Unit tests

'PNConfiguration.UseRandomInitializationVector' is obsolete: 'UseRandomInitializationVector is deprecated, please use CryptoModule instead.'

Check warning on line 33 in src/Api/PubnubApi/Security/SecureMessage.cs

View workflow job for this annotation

GitHub Actions / Acceptance tests

'PNConfiguration.CipherKey' is obsolete: 'CipherKey is deprecated, please use CryptoModule instead.'

Check warning on line 33 in src/Api/PubnubApi/Security/SecureMessage.cs

View workflow job for this annotation

GitHub Actions / Acceptance tests

'PNConfiguration.UseRandomInitializationVector' is obsolete: 'UseRandomInitializationVector is deprecated, please use CryptoModule instead.'

Check warning on line 33 in src/Api/PubnubApi/Security/SecureMessage.cs

View workflow job for this annotation

GitHub Actions / Publish to NuGet

'PNConfiguration.CipherKey' is obsolete: 'CipherKey is deprecated, please use CryptoModule instead.'

Check warning on line 33 in src/Api/PubnubApi/Security/SecureMessage.cs

View workflow job for this annotation

GitHub Actions / Publish to NuGet

'PNConfiguration.UseRandomInitializationVector' is obsolete: 'UseRandomInitializationVector is deprecated, please use CryptoModule instead.'
object[] myObjectArray = (from item in messageList
select item as object).ToArray();
object[] enumerable = myObjectArray[0] as object[];
Expand Down Expand Up @@ -68,12 +68,10 @@
{
status.AffectedChannelGroups.AddRange(channelGroups);
}

errorCallback.OnResponse(default(T), status);
Comment on lines -71 to -72
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ohhh, I missed this during the previous change ;o?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is fine!

pubnubLog.WriteToLog("Failed to decrypt message!\nMessage might be not encrypted, returning as is...");
}
pubnubLog.WriteToLog("Failed to decrypt message!\nMessage might be not encrypted, returning as is...");
object decodeMessage = jsonLib.DeserializeToObject((decryptMessage == "**DECRYPT ERROR**") ? element.ToString() : decryptMessage);
receivedMsg.Add(decodeMessage);
object decodedMessage = jsonLib.DeserializeToObject((decryptMessage == "**DECRYPT ERROR**") ? jsonLib.SerializeToJsonString(element) : decryptMessage);
receivedMsg.Add(decodedMessage);
}
returnMessage.Add(receivedMsg);
}
Expand Down Expand Up @@ -128,9 +126,9 @@
Dictionary<string, object> dicDecrypt = new Dictionary<string, object>();
foreach (KeyValuePair<string, object> kvpValue in dicValue)
{
if (kvpValue.Key == "message" && (config.CryptoModule != null || config.CipherKey.Length > 0))

Check warning on line 129 in src/Api/PubnubApi/Security/SecureMessage.cs

View workflow job for this annotation

GitHub Actions / Integration and Unit tests

'PNConfiguration.CipherKey' is obsolete: 'CipherKey is deprecated, please use CryptoModule instead.'

Check warning on line 129 in src/Api/PubnubApi/Security/SecureMessage.cs

View workflow job for this annotation

GitHub Actions / Acceptance tests

'PNConfiguration.CipherKey' is obsolete: 'CipherKey is deprecated, please use CryptoModule instead.'

Check warning on line 129 in src/Api/PubnubApi/Security/SecureMessage.cs

View workflow job for this annotation

GitHub Actions / Publish to NuGet

'PNConfiguration.CipherKey' is obsolete: 'CipherKey is deprecated, please use CryptoModule instead.'
{
config.CryptoModule ??= new CryptoModule(new LegacyCryptor(config.CipherKey, config.UseRandomInitializationVector, pubnubLog), null);

Check warning on line 131 in src/Api/PubnubApi/Security/SecureMessage.cs

View workflow job for this annotation

GitHub Actions / Integration and Unit tests

'PNConfiguration.CipherKey' is obsolete: 'CipherKey is deprecated, please use CryptoModule instead.'

Check warning on line 131 in src/Api/PubnubApi/Security/SecureMessage.cs

View workflow job for this annotation

GitHub Actions / Integration and Unit tests

'PNConfiguration.UseRandomInitializationVector' is obsolete: 'UseRandomInitializationVector is deprecated, please use CryptoModule instead.'

Check warning on line 131 in src/Api/PubnubApi/Security/SecureMessage.cs

View workflow job for this annotation

GitHub Actions / Acceptance tests

'PNConfiguration.CipherKey' is obsolete: 'CipherKey is deprecated, please use CryptoModule instead.'

Check warning on line 131 in src/Api/PubnubApi/Security/SecureMessage.cs

View workflow job for this annotation

GitHub Actions / Acceptance tests

'PNConfiguration.UseRandomInitializationVector' is obsolete: 'UseRandomInitializationVector is deprecated, please use CryptoModule instead.'

Check warning on line 131 in src/Api/PubnubApi/Security/SecureMessage.cs

View workflow job for this annotation

GitHub Actions / Publish to NuGet

'PNConfiguration.CipherKey' is obsolete: 'CipherKey is deprecated, please use CryptoModule instead.'

Check warning on line 131 in src/Api/PubnubApi/Security/SecureMessage.cs

View workflow job for this annotation

GitHub Actions / Publish to NuGet

'PNConfiguration.UseRandomInitializationVector' is obsolete: 'UseRandomInitializationVector is deprecated, please use CryptoModule instead.'
string decryptMessage = "";
try
{
Expand All @@ -151,13 +149,11 @@
{
status.AffectedChannelGroups.AddRange(channelGroups);
}

errorCallback.OnResponse(default(T), status);
pubnubLog.WriteToLog("Failed to decrypt message!\nMessage might be not encrypted, returning as is...");
#endregion
}
pubnubLog.WriteToLog("Failed to decrypt message!\nMessage might be not encrypted, returning as is...");
object decodeMessage = jsonLib.DeserializeToObject((decryptMessage == "**DECRYPT ERROR**") ? decryptMessage : decryptMessage);
dicDecrypt.Add(kvpValue.Key, decodeMessage);
object decodedMessage = jsonLib.DeserializeToObject((decryptMessage == "**DECRYPT ERROR**") ? jsonLib.SerializeToJsonString(kvpValue.Value) : decryptMessage);
dicDecrypt.Add(kvpValue.Key, decodedMessage);
}
else
{
Expand Down
4 changes: 2 additions & 2 deletions src/Api/PubnubApiPCL/PubnubApiPCL.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@

<PropertyGroup>
<PackageId>PubnubPCL</PackageId>
<PackageVersion>6.19.4.0</PackageVersion>
<PackageVersion>6.19.5.0</PackageVersion>
<Title>PubNub C# .NET - Web Data Push API</Title>
<Authors>Pandu Masabathula</Authors>
<Owners>PubNub</Owners>
<PackageLicenseFile>LICENSE.txt</PackageLicenseFile>
<PackageIconUrl>http://pubnub.s3.amazonaws.com/2011/powered-by-pubnub/pubnub-icon-600x600.png</PackageIconUrl>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<RepositoryUrl>https://github.com/pubnub/c-sharp/</RepositoryUrl>
<PackageReleaseNotes>Handle unencrypted message while getting messages with crypto.</PackageReleaseNotes>
<PackageReleaseNotes>Fixes issue of getting exception for custom objects in subscription and history when crypto module is configured.</PackageReleaseNotes>
<PackageTags>Web Data Push Real-time Notifications ESB Message Broadcasting Distributed Computing</PackageTags>
<!--<Summary>PubNub is a Massively Scalable Web Push Service for Web and Mobile Games. This is a cloud-based service for broadcasting messages to thousands of web and mobile clients simultaneously</Summary>-->
<Description>PubNub is a Massively Scalable Web Push Service for Web and Mobile Games. This is a cloud-based service for broadcasting messages to thousands of web and mobile clients simultaneously</Description>
Expand Down
4 changes: 2 additions & 2 deletions src/Api/PubnubApiUWP/PubnubApiUWP.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@

<PropertyGroup>
<PackageId>PubnubUWP</PackageId>
<PackageVersion>6.19.4.0</PackageVersion>
<PackageVersion>6.19.5.0</PackageVersion>
<Title>PubNub C# .NET - Web Data Push API</Title>
<Authors>Pandu Masabathula</Authors>
<Owners>PubNub</Owners>
<PackageLicenseFile>LICENSE.txt</PackageLicenseFile>
<PackageIconUrl>http://pubnub.s3.amazonaws.com/2011/powered-by-pubnub/pubnub-icon-600x600.png</PackageIconUrl>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<RepositoryUrl>https://github.com/pubnub/c-sharp/</RepositoryUrl>
<PackageReleaseNotes>Handle unencrypted message while getting messages with crypto.</PackageReleaseNotes>
<PackageReleaseNotes>Fixes issue of getting exception for custom objects in subscription and history when crypto module is configured.</PackageReleaseNotes>
<PackageTags>Web Data Push Real-time Notifications ESB Message Broadcasting Distributed Computing</PackageTags>
<!--<Summary>PubNub is a Massively Scalable Web Push Service for Web and Mobile Games. This is a cloud-based service for broadcasting messages to thousands of web and mobile clients simultaneously</Summary>-->
<Description>PubNub is a Massively Scalable Web Push Service for Web and Mobile Games. This is a cloud-based service for broadcasting messages to thousands of web and mobile clients simultaneously</Description>
Expand Down
2 changes: 1 addition & 1 deletion src/Api/PubnubApiUnity/PubnubApiUnity.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

<PropertyGroup>
<PackageId>PubnubApiUnity</PackageId>
<PackageVersion>6.19.4.0</PackageVersion>
<PackageVersion>6.19.5.0</PackageVersion>
<Title>PubNub C# .NET - Web Data Push API</Title>
<Authors>Pandu Masabathula</Authors>
<Owners>PubNub</Owners>
Expand Down
Loading