Created
March 3, 2020 21:31
Revisions
-
funkysi1701 created this gist
Mar 3, 2020 .There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,22 @@ [Fact] public void IsSSLExpiring() { var handler = new HttpClientHandler { ServerCertificateCustomValidationCallback = CustomCallback }; var client = new HttpClient(handler); HttpResponseMessage response = client.GetAsync("https://www.example.com").GetAwaiter().GetResult(); Assert.True(response.IsSuccessStatusCode); } private bool CustomCallback(HttpRequestMessage arg1, X509Certificate2 arg2, X509Chain arg3, SslPolicyErrors arg4) { var now = DateTime.UtcNow; var expire = arg2.NotAfter; var diff = (expire - now).TotalDays; Assert.InRange(diff, 30, 1000); return arg4 == SslPolicyErrors.None; }