top of page

PowerShell - Test SSL support/versions of Website(s)

  • Writer: Jon Boyette
    Jon Boyette
  • Jan 10, 2022
  • 1 min read

Save as a .ps1, prompts for the webserver name, Lists TLS and SSL versions supported and Ciphers

$a = Read-Host "Enter Your Webserver Name"

function Test-ServerSSLSupport {

[CmdletBinding()]

param(

[Parameter(Mandatory = $true, ValueFromPipeline = $true)]

[ValidateNotNullOrEmpty()]

[string]$HostName,

[UInt16]$Port = 443

)

process {

$RetValue = New-Object psobject -Property @{

Host = $HostName

Port = $Port

SSLv2 = $false

SSLv3 = $false

TLSv1_0 = $false

TLSv1_1 = $false

TLSv1_2 = $false

KeyExhange = $null

HashAlgorithm = $null

}

“ssl2”, “ssl3”, “tls”, “tls11”, “tls12” | %{

$TcpClient = New-Object Net.Sockets.TcpClient

$TcpClient.Connect($RetValue.Host, $RetValue.Port)

$SslStream = New-Object Net.Security.SslStream $TcpClient.GetStream()

$SslStream.ReadTimeout = 15000

$SslStream.WriteTimeout = 15000

try {

$SslStream.AuthenticateAsClient($RetValue.Host,$null,$_,$false)

$RetValue.KeyExhange = $SslStream.KeyExchangeAlgorithm

$RetValue.HashAlgorithm = $SslStream.HashAlgorithm

$status = $true

} catch {

$status = $false

}

switch ($_) {

“ssl2” {$RetValue.SSLv2 = $status}

“ssl3” {$RetValue.SSLv3 = $status}

“tls” {$RetValue.TLSv1_0 = $status}

“tls11” {$RetValue.TLSv1_1 = $status}

“tls12” {$RetValue.TLSv1_2 = $status}

}


# dispose objects to prevent memory leaks

#$TcpClient.Dispose()

#$SslStream.Dispose()

}

$RetValue

“From “+ $TcpClient.client.LocalEndPoint.address.IPAddressToString +” to $hostname “+ $TcpClient.client.RemoteEndPoint.address.IPAddressToString +’:’+$TcpClient.client.RemoteEndPoint.port

$SslStream |gm |?{$_.MemberType -match ‘Property’}|Select-Object Name |%{$_.Name +’: ‘+ $sslStream.($_.name)}

}

}


Test-ServerSSLSupport $a


 
 
 

Recent Posts

See All
PowerShell - List All Domain SPNs

Save as same List_ALL_SPNs.ps1 or similar, this LDap calls the Domain for all Service Principal names and accounts related #Build LDAP...

 
 
 
PowerShell - Start-Monitoring

This is a great script used to Monitor and Email if a server is up or down, once ran, and smtp and from address is set, then run:...

 
 
 

Comments


Post: Blog2 Post
  • Facebook
  • Twitter
  • LinkedIn

©2022 by Boyette Technical Services. Proudly created with Wix.com

bottom of page