Verify with a NTP time source before continuing
This commit is contained in:
parent
a7560d75d9
commit
73c6317b3e
|
|
@ -13,6 +13,22 @@
|
|||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
<Deterministic>true</Deterministic>
|
||||
<TargetFrameworkProfile />
|
||||
<PublishUrl>C:\Users\curriegrad2004\Desktop\MFAGenerator\</PublishUrl>
|
||||
<Install>true</Install>
|
||||
<InstallFrom>Disk</InstallFrom>
|
||||
<UpdateEnabled>false</UpdateEnabled>
|
||||
<UpdateMode>Foreground</UpdateMode>
|
||||
<UpdateInterval>7</UpdateInterval>
|
||||
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
|
||||
<UpdatePeriodically>false</UpdatePeriodically>
|
||||
<UpdateRequired>false</UpdateRequired>
|
||||
<MapFileExtensions>true</MapFileExtensions>
|
||||
<ApplicationRevision>0</ApplicationRevision>
|
||||
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
|
||||
<IsWebBootstrapper>false</IsWebBootstrapper>
|
||||
<UseApplicationTrust>false</UseApplicationTrust>
|
||||
<PublishWizardCompleted>true</PublishWizardCompleted>
|
||||
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
|
|
@ -33,7 +49,22 @@
|
|||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<ManifestCertificateThumbprint>25959F1C21FCA9FFDED624C1BC14F6D1248B0FDD</ManifestCertificateThumbprint>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<ManifestKeyFile>MFACodeGenerator_TemporaryKey.pfx</ManifestKeyFile>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<GenerateManifests>true</GenerateManifests>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<SignManifests>true</SignManifests>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="NtpClient, Version=1.0.14.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\NtpClient.1.0.14\lib\net40\NtpClient.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Otp.NET, Version=1.2.2.0, Culture=neutral, PublicKeyToken=38a48df817e173a6, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Otp.NET.1.2.2\lib\net45\Otp.NET.dll</HintPath>
|
||||
</Reference>
|
||||
|
|
@ -70,6 +101,7 @@
|
|||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
<None Include="MFACodeGenerator_TemporaryKey.pfx" />
|
||||
<None Include="packages.config" />
|
||||
<None Include="Properties\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
|
|
@ -84,5 +116,12 @@
|
|||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>.NET Framework 3.5 SP1</ProductName>
|
||||
<Install>false</Install>
|
||||
</BootstrapperPackage>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
|
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
|||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using NtpClient;
|
||||
|
||||
namespace MFACodeGenerator
|
||||
{
|
||||
|
|
@ -14,6 +15,29 @@ namespace MFACodeGenerator
|
|||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
try
|
||||
{
|
||||
NtpClient.NtpConnection client
|
||||
= new NtpConnection("pool.ntp.org");
|
||||
var NetDate = client.GetUtc();
|
||||
|
||||
var diff = NetDate - DateTime.UtcNow;
|
||||
|
||||
if (Math.Abs(diff.Seconds) >= 60)
|
||||
{
|
||||
MessageBox.Show("Time difference is greater than 60 seconds. Please check your local clock settings!",
|
||||
"Clock Drift Detected",
|
||||
MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
} catch
|
||||
{
|
||||
MessageBox.Show("Since we can't verify your PC's clock to a reliable time source, this application may not work properly. Please ensure the time on your PC is set correctly.",
|
||||
"No Reliable Time Source Found"
|
||||
, MessageBoxButtons.OK
|
||||
, MessageBoxIcon.Warning);
|
||||
}
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
Application.Run(new Form1());
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="NtpClient" version="1.0.14" targetFramework="net45" />
|
||||
<package id="Otp.NET" version="1.2.2" targetFramework="net46" />
|
||||
</packages>
|
||||
Loading…
Reference in New Issue