i have an C# solution which contains two projects, one is main application and another is license project. Project is working smoothly. i have used json to serialize the license detail. now i need to do obfuscation on my licensing project to make it safe from frauds or hackers. I have used Dotfuscator
for obfuscation purpose. i have used below's line to deserialize the license details received by application.
xmlDocument.LoadXml(xml);
details = xmlDocument.SelectSingleNode("/license/details");
licenseDetails = JsonConvert.DeserializeObject<LicenseDetails>(details.InnerText);
this line returns unknown object I
after obfuscation but it was working good before obfuscation.
return value before obfuscation
licenseDetails == Shared.Licensing.Client.LicenseDetails
return value after obfuscation
licenseDetails = I
My XML file is
<?xml version="1.0" encoding="utf-8"?>
<license>
<details>{"Product":"Outlook Templates","ProductVersion":"1.0.0.0","Username":"Demo","Serial":"1fKxUCJylsm+qVUccjUn8gYNVgDc4pE5OuqYs48vkaQ=","RegistrationDate":"\/Date(1326202832909+0200)\/","ExpirationDate":"\/Date(1330387200000)\/","PayloadEntries":[{"ValueType":2,"EntryName":"MaxNumProviders","Operation":1,"EntryValue":"3"},{"ValueType":2,"EntryName":"MaxNumQuick","Operation":1,"EntryValue":"5"},{"ValueType":2,"EntryName":"ExpirationDaysOffset","Operation":1,"EntryValue":"30"}]}</details>
<Signature xmlns="http://www.w3.org/2000/09/xmldsig#">
<SignedInfo>
<CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315" />
<SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1" />
<Reference URI="">
<Transforms>
<Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature" />
</Transforms>
<DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />
<DigestValue>c/BK0YOhnW8cXUGxTJx3mpWQj1U=</DigestValue>
</Reference>
</SignedInfo>
<SignatureValue>gWYcpr3OBhUoiPEFyWskgoRcDw5rO2RWNbMulXSXg2tsKWebEFqgptCUfr7JRvvSjm4kALyvU7mZviJI/peJWmJC69gs7QDMEOWLvrOa0TL1qyO5K5onCBZopJUdrPE0PJCVYRacasI3DvTOSo+IDEOSFVpEWZNcERhB6ZkOFrU=</SignatureValue>
</Signature>
</license>
I don't know what does go wrong during obfuscation.
You'll have to exclude the properties of LicenseDetails
exposed by JSON from renaming.
Alternatively, if you don't want to expose those names, you could manually convert from Json to your LicenseDetails text in a way that doesn't involve reflection. You could use something like this I think:
var json=new JObject(details.InnerText);
var license=new LicenseDetails();
license.Product=json["Product"];
license.ProductVersion=json["ProductVersion"];
....
Note it requires a lot more work though doing it manually like this.