Portable.Licensing icon indicating copy to clipboard operation
Portable.Licensing copied to clipboard

InvalidSignatureValidationFailure: License signature validation error!

Open pankajmcait opened this issue 9 years ago • 6 comments

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 avatar Feb 21 '17 05:02 pankajmcait

Is there any update from anyone?

pankajmcait avatar Mar 06 '17 05:03 pankajmcait

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.

qmfrederik avatar May 04 '17 12:05 qmfrederik

Always there is error!!

pankajmcait avatar May 05 '17 04:05 pankajmcait

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.

yolita15 avatar Dec 13 '17 13:12 yolita15

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

On Wed, Dec 13, 2017 at 7:23 PM, Yoanna [email protected] 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

pankajmcait avatar Dec 14 '17 04:12 pankajmcait

@pankajmcait well... did it work?

nikro412956 avatar Mar 04 '19 12:03 nikro412956