Rhino-Licensing for .NET is throwing an LicenseExpiredException

990 views Asked by At

I'm using Windows 8.1 with latest .NET core, and Visual Studio 2015. I followed the following article from James Gregory to create a Winform app. But when I assert the license, it gives me the following error: Rhino.Licensing.LicenseExpiredException was unhandled HResult=-2146233088 Message=Expiration Date : 6/16/2016 12:00:00 AM Source=Rhino.Licensing StackTrace: at Rhino.Licensing.AbstractLicenseValidator.HasExistingLicense() at Rhino.Licensing.AbstractLicenseValidator.AssertValidLicense() at Rhino.Licensing.LicenseValidator.AssertValidLicense() at Winfrm_RhinoTest.Form1.ApplyLicense()....

The code ran on June 15, 2016 and the expiration date was set to June 16, 2016.

The C# code to generate the license is as follows:

string publicKey = File.ReadAllText("publicKey.xml");
            new LicenseValidator(publicKey, @"C:\Users\Public\license.xml").AssertValidLicense();

The license.xml file was generated and used in the code as follows:

<?xml version="1.0" encoding="utf-8"?>
<license id="b45c43a5-a639-4fa4-8bf7-38531b19072e" expiration="2016-06-16T00:00:00.0000000" type="Trial">
  <name>Bilbo</name>
  <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>d+eI2/Bdp/VYJ8pi/ufmJGeRW6k=</DigestValue>
      </Reference>
    </SignedInfo>
    <SignatureValue>Zd2oTinP0zE4/4haA5e4810MdG3upx1LlzkXALsTJYDgXLacDoc96diObTkxDipUBMUeFuf3ARBPtFRHGIqHjEfhn/FqZD+CrcsvjhbMSIROpaqqcOpzFwOamjQ+jPLW+BOf5qvMA0n4LNCm8B5qnifc/08zTXTSUpAqLiCY8zk=</SignatureValue>
  </Signature>
</license>
1

There are 1 answers

1
Martheen On BEST ANSWER

In the source code for rhino-licensing, the date comparison is done in UTC

result = DateTime.UtcNow < ExpirationDate;

Which will throw the exception with Expiration Date as parameter

throw new LicenseExpiredException("Expiration Date : " + ExpirationDate)

Since the exception you shown indicate the ExpirationDate is the start of 16 June, the most likely reason is you're running the code in 15 June in your timezone, that is actually already 16 June in UTC, which is 19 hours already at the time of this post.