lib/Set-JenkinsTLSSupport.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<#
    .SYNOPSIS
        Enables PowerShell to support TLS1.2 for communicating with
        newer versions of Jenkins.
 
    .DESCRIPTION
        This support cmdlet enables connecting to newer versions of
        Jenkins over HTTPS. Newer versions of Jenkins have deprecated
        support for SSL3/TLS, which are the default supported HTTPS
        protocols.
 
    .OUTPUTS
        None
#>

function Set-JenkinsTLSSupport
{
    [CmdLetBinding()]
    param
    (
    )

    if (-not ([Net.ServicePointManager]::SecurityProtocol).ToString().Contains([Net.SecurityProtocolType]::Tls12))
    {
        [Net.ServicePointManager]::SecurityProtocol = `
            [Net.ServicePointManager]::SecurityProtocol.toString() + ', ' + [Net.SecurityProtocolType]::Tls12
    }
} # function Set-JenkinsTLSSupport