junian / Standard.Licensing

Easy-to-use licensing library for .NET Framework, Mono, .NET Core, and MAUI / Xamarin products
https://junian.dev/Standard.Licensing/
MIT License
554 stars 127 forks source link

The license signature and data does not match. #11

Open dhineshmuthuvel opened 4 years ago

dhineshmuthuvel commented 4 years ago

Followed the steps mentioned in the readme, however getting the error in the validationfailures.ToList(). Any Idea on this ?

The license signature and data does not match. This usually happens when a license file is corrupted or has been altered.

public static bool ValidateLicense(string publicKey)
        {
            var readAllLines = File.ReadAllText(@"D:\Work Items\KiteConnect\LicensingPOC\LicensingPOC\License.lic");
            var license = License.Load(readAllLines);

            var validationFailures = license.Validate()
                .ExpirationDate()
                .When(lic => lic.Type == LicenseType.Trial)
                .And()
                .Signature(publicKey).AssertValidLicense();

            List<IValidationFailure> failures = validationFailures.ToList();

            return !failures.Any();
        }
ZiTsi commented 4 years ago

Are you using the File.WriteAllText("License.lic", license.ToString(), Encoding.UTF8); way to save the license to a file?

If so try the second one, ie: using (var xmlWriter = System.Xml.XmlWriter.Create(filePath)) { license.Save(xmlWriter); }

ChristophBachmann commented 4 years ago

I had the same issue. Your solution (using seconde one with xmlWriter) resolved the issue.

valimaties commented 4 years ago

Mine does not work at all. Neither the first, neither the second solution, both of them generates "Data at the root level is invalid: Line 1, position 1."

leonkosak commented 4 years ago

Offtopic question. Is this project still maintained?

valimaties commented 4 years ago

Offtopic question. Is this project still maintained?

I don't think so @leonkosak

skst commented 7 months ago

Yes, it was just upgraded to .NET 8.