Check Certificate Expiry Date in .NET Core | Steve Fenton
DateTime notAfter = DateTime.UtcNow; var httpClientHandler = new HttpClientHandler { ServerCertificateCustomValidationCallback = (request, cert, chain, policyErrors) => { notAfter = cert.NotAfter; return true; } }; using HttpClient httpClient = new HttpClient(httpClientHandler); await httpClient.SendAsync(new HttpRequestMessage(HttpMethod.Head, url)); Assert.IsTrue(notAfter > DateTime.UtcNow.AddDays(60));
Comments
Post a Comment