Skip to content

Instantly share code, notes, and snippets.

@pkutaj
Created February 19, 2021 09:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pkutaj/41c23b03df9c4e5a379f8e3904051cde to your computer and use it in GitHub Desktop.
Save pkutaj/41c23b03df9c4e5a379f8e3904051cde to your computer and use it in GitHub Desktop.
test-certificate.ps1
function test-certificate($domain, $contextLength = 10) {
$cacertPath = "c:\cacert.pem"
$domain += ":443"
echo "q" | openssl s_client -connect $domain -CAfile $cacertPath | openssl x509 -noout -enddate | sls "notAfter.*"
echo "q" | openssl s_client -connect $domain -CAfile $cacertPath | sls "certificate chain" -Context $contextLength
Write-Host "~~~" -ForegroundColor darkcyan
Write-Host "→ If needed, pass a desired output length after domainname" -ForegroundColor darkcyan
Write-Host "→ To update the list of trusted Certificates, run:" -ForegroundColor darkcyan
Write-Host "→ Invoke-WebRequest https://curl.se/ca/cacert.pem -OutFile 'c:\cacert.pem'" -ForegroundColor darkcyan
Write-Host "~~~" -ForegroundColor darkcyan
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment