Skip to content

Commit a832ada

Browse files
committed
Add examples to ConvertTo-TlsProtocolRegistryKeyName and Test-TlsProtocol functions
1 parent fa8e995 commit a832ada

2 files changed

Lines changed: 17 additions & 5 deletions

File tree

source/Private/ConvertTo-TlsProtocolRegistryKeyName.ps1

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@
1111
1212
.OUTPUTS
1313
System.String
14+
15+
.EXAMPLE
16+
ConvertTo-TlsProtocolRegistryKeyName -Protocol Tls12
17+
18+
Returns the string 'TLS 1.2'.
1419
#>
1520
function ConvertTo-TlsProtocolRegistryKeyName
1621
{

source/Public/Test-TlsProtocol.ps1

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,24 @@
2020
2121
.OUTPUTS
2222
System.Boolean
23+
24+
.EXAMPLE
25+
Test-TlsProtocol -Protocol Tls12
26+
27+
Tests if TLS 1.2 is enabled for server-side connections.
28+
29+
.EXAMPLE
30+
Test-TlsProtocol -Protocol Tls13 -Client
31+
32+
Tests if TLS 1.3 is enabled for client-side connections.
2333
#>
2434
function Test-TlsProtocol
2535
{
2636
[CmdletBinding()]
2737
[OutputType([System.Boolean])]
2838
param
2939
(
40+
# TODO: Should use enum [System.Security.Authentication.SslProtocols]
3041
[Parameter(Mandatory = $true)]
3142
[ValidateSet('Ssl2', 'Ssl3', 'Tls', 'Tls11', 'Tls12', 'Tls13', IgnoreCase = $true)]
3243
[System.String[]]
@@ -43,11 +54,7 @@ function Test-TlsProtocol
4354

4455
foreach ($p in $Protocol)
4556
{
46-
$protocolTarget = if ($Client.IsPresent) { 'Client' } else { 'Server' }
47-
48-
$protocolKeyName = ConvertTo-TlsProtocolRegistryKeyName -Protocol $p
49-
50-
$regPath = "HKLM:\\SYSTEM\\CurrentControlSet\\Control\\SecurityProviders\\SCHANNEL\\Protocols\\$protocolKeyName\\$protocolTarget"
57+
$regPath = Get-TlsProtocolRegistryPath -Protocol $p -Client:$Client
5158

5259
$protocolEnabled = Get-RegistryPropertyValue -Path $regPath -Name 'Enabled' -ErrorAction SilentlyContinue
5360
$protocolDisabled = Get-RegistryPropertyValue -Path $regPath -Name 'DisabledByDefault' -ErrorAction SilentlyContinue

0 commit comments

Comments
 (0)