Forum Discussion
Joe_Williams
5 years agoProfessor
Guessing it hasn't been approved yet. Below is the PowerShell script and the AppliesTo is 'auto.activedatasources =~ "HTTPS"'
$URL = "https://" $URL = $URL + "##hostname##" try { [Net.ServicePointManager]::ServerCertificateValidationCallback = {$true} $webRequest = [System.Net.HttpWebRequest]::Create($URL) $webRequest.KeepAlive = $false $webRequest.Timeout = 5000 $webRequest.ServicePoint.ConnectionLeaseTimeout = 5000 $webRequest.ServicePoint.MaxIdleTime = 5000 #$null = $webRequest.GetResponse() $null = $webRequest.GetResponse().Dispose() } catch [System.Net.WebException] { if ($_.Exception.Status -eq [System.Net.WebExceptionStatus]::TrustFailure) { # We ignore trust failures, since we only want the certificate, and the service point is still populated at this point } else { # Write-Warning $_.Exception.Message } } catch { # Write-Warning $_.Exception.Message } if (($webRequest.ServicePoint.Certificate) -and ($webRequest.ServicePoint.Certificate.Handle -ne 0)) { if ($ReturnCertificate) { # Write-Output $webRequest.ServicePoint.Certificate } else { $IssuerCN = $webRequest.ServicePoint.Certificate.Issuer.Split(', ',[System.StringSplitOptions]::RemoveEmptyEntries)[0].Split('=')[1] $SubjectCN = $webRequest.ServicePoint.Certificate.Subject.Split(', ',[System.StringSplitOptions]::RemoveEmptyEntries)[0].Split('=')[1] $ValidFrom = $webRequest.ServicePoint.Certificate.GetEffectiveDateString() $ValidTo = $webRequest.ServicePoint.Certificate.GetExpirationDateString() Write-Host "certificate.IssuerCN=$IssuerCN" Write-Host "certificate.SubjectCN=$SubjectCN" Write-Host "certificate.ValidFrom=$ValidFrom" Write-Host "certificate.ValidTo=$ValidTo" } $webRequest.ServicePoint.Certificate.Dispose() } [Net.ServicePointManager]::ServerCertificateValidationCallback = $null
Related Content
- 8 months ago
- 5 years ago