Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ValidateUsingNetworkTime #32

Open
nielstanghe opened this issue Nov 15, 2017 · 0 comments
Open

ValidateUsingNetworkTime #32

nielstanghe opened this issue Nov 15, 2017 · 0 comments

Comments

@nielstanghe
Copy link

nielstanghe commented Nov 15, 2017

I've encountered a problem while testing the network time validation. My test:

  • The license-file that I was testing was already expired
  • I've set my clock to a day before the license expire date
  • Loading the license and calling 'AssertValidLicense'

When I noticed that I didn't get any exception, I started digging..
I noticed that the exception gets lost in the sntp.BeginGetDate-thread. I don't know if i'm doing something wrong, but to continue my testing I've added a quick fix (I'm struggling with inserting code, but you'll get the point):

`
private void ValidateUsingNetworkTime()
{
if (!NetworkInterface.GetIsNetworkAvailable())
return;

        bool isLicenseValid = true;
        ManualResetEvent timeRequestDone = new ManualResetEvent(false);

        var sntp = new SntpClient(GetTimeServers());
        sntp.BeginGetDate(time =>
        {
            if (time > ExpirationDate)
                isLicenseValid = true;

            timeRequestDone.Set();
        }
        , () =>
        {
            /* ignored */
        });

        timeRequestDone.WaitOne();
        if (!isLicenseValid)
            RaiseLicenseInvalidated();

    }`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant