Skip to content

Instantly share code, notes, and snippets.

@ml4den
Created October 15, 2018 16:11
Show Gist options
  • Select an option

  • Save ml4den/5ba24a5da34757f804754f24aa45bbe0 to your computer and use it in GitHub Desktop.

Select an option

Save ml4den/5ba24a5da34757f804754f24aa45bbe0 to your computer and use it in GitHub Desktop.
Rudimentary PowerShell function for checking host certificate grades using the SSL Labs API
Function Get-HostCertificateGrade ($hostname) {
# Rudimentary function for checking host certificate grades using the SSL Labs API
# https://github.com/ssllabs/ssllabs-scan/blob/master/ssllabs-api-docs-v3.md
Do {
$apiCall = Invoke-RestMethod -Uri "https://api.ssllabs.com/api/v3/analyze?host=$hostname&fromCache=on"
Write-Host $hostname "status:" $apiCall.status
if ($apiCall.status -eq "DNS") {Start-Sleep -Seconds 5}
elseif ($apiCall.status -eq "IN_PROGRESS") {Start-Sleep -Seconds 10}
} Until ($apiCall.status -eq "READY")
Write-Host $hostname "grade:" $apiCall.endpoints.grade
foreach ($endpoint in $apiCall.endpoints) {
$ipAddress = $endpoint.ipAddress
$grade = $endpoint.grade
$functionOutput = @{
IPAddress = $ipaddress
Grade = $grade
}
New-Object -TypeName PSObject -Property $functionOutput
}
}
$output = Get-HostCertificateGrade -hostname google.com
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment