dnauck / Portable.Licensing

Portable.Licensing is a cross platform software licensing framework which allows you to implement licensing into your application or library. It provides you all tools to create and validate licenses for your software.
http://dev.nauck-it.de/projects/portable-licensing
MIT License
592 stars 173 forks source link

InvalidSignatureValidationFailure: License signature validation error! #40

Open pankajmcait opened 7 years ago

pankajmcait commented 7 years ago

While validating the License, following error is coming out:

InvalidSignatureValidationFailure: License signature validation error! - The license signature and data does not match. This usually happens when a license file is corrupted or has been altered.

Using the following code for validation: string licPath = Server.MapPath("~\LicenseFiles\License.lic"); var keypath = Server.MapPath("~\LicenseFiles\public-key.txt"); string publicKey = System.IO.File.ReadAllText(keypath, System.Text.Encoding.UTF8);

        StringBuilder sb = new StringBuilder();
        using (XmlReader reader = XmlReader.Create(licPath))
        {

            License readLicence = License.Load(reader);
            var validationFailures = readLicence.Validate()
              .ExpirationDate()
                   .When(lic => lic.Type == LicenseType.Trial)
              .And()
              .Signature(publicKey)
              .AssertValidLicense().ToList();

            foreach (var failure in validationFailures)
                sb.Append(failure.GetType().Name + ": " + failure.Message + " - " + failure.HowToResolve);
        }

Can anybody suggest why is this happening? @dnauck

pankajmcait commented 7 years ago

Is there any update from anyone?

qmfrederik commented 7 years ago

Do you always get this error or just intermittently? license.Validate()>Signature(publicKey) is not thread safe, and you may get this errors if you have multiple threads entering this code at the same time.

pankajmcait commented 7 years ago

Always there is error!!

yolita15 commented 6 years ago

Do not use that

using (XmlReader reader = XmlReader.Create(licPath))

just pass it as a string :

string reader = File.ReadAllText(licPath);
 License readLicence = License.Load(reader);
            var validationFailures = readLicence.Validate()
              .ExpirationDate()
                   .When(lic => lic.Type == LicenseType.Trial)
              .And()
              .Signature(publicKey)
              .AssertValidLicense().ToList();

            foreach (var failure in validationFailures)
                sb.Append(failure.GetType().Name + ": " + failure.Message + " - " + failure.HowToResolve);`

This should work.

pankajmcait commented 6 years ago

okay, i will try this code and let you know...

On Wed, Dec 13, 2017 at 7:23 PM, Yoanna notifications@github.com wrote:

Do not use that

using (XmlReader reader = XmlReader.Create(licPath))

just pass it as a string :

`string reader = File.ReadAllText(licPath ); License readLicence = License.Load(reader); var validationFailures = readLicence.Validate() .ExpirationDate() .When(lic => lic.Type == LicenseType.Trial) .And() .Signature(publicKey) .AssertValidLicense().ToList();

    foreach (var failure in validationFailures)
        sb.Append(failure.GetType().Name + ": " + failure.Message + " - " + failure.HowToResolve);`

This should work.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/dnauck/Portable.Licensing/issues/40#issuecomment-351397089, or mute the thread https://github.com/notifications/unsubscribe-auth/AYt8_GmxuJiJ9pbWRnAE3tOqKOL4hrboks5s_9bcgaJpZM4MG4ea .

--

ThanksPankaj Jain+91 9871844292

nikro412956 commented 5 years ago

@pankajmcait well... did it work?