Fixes TLS error on WebRequests for endpoints using TLS 1.2

Fixes #86
This commit is contained in:
Christian Stein 2020-07-31 10:20:53 +02:00
parent aa8d712152
commit 0ba6fd35f4
9 changed files with 14 additions and 0 deletions

View file

@ -37,6 +37,7 @@ function Get-IcingaDirectorSelfServiceConfig()
throw 'Please enter either a template or your host key. If this message persists, ensure your host is not having a template key assigned already. If so, you can try dropping it within the Icinga Director.'; throw 'Please enter either a template or your host key. If this message persists, ensure your host is not having a template key assigned already. If so, you can try dropping it within the Icinga Director.';
} }
Set-IcingaTLSVersion;
$ProgressPreference = "SilentlyContinue"; $ProgressPreference = "SilentlyContinue";
$EndpointUrl = Join-WebPath -Path $DirectorUrl -ChildPath ([string]::Format('/self-service/powershell-parameters?key={0}', $ApiKey)); $EndpointUrl = Join-WebPath -Path $DirectorUrl -ChildPath ([string]::Format('/self-service/powershell-parameters?key={0}', $ApiKey));

View file

@ -38,6 +38,8 @@ function Get-IcingaDirectorSelfServiceTicket()
return; return;
} }
Set-IcingaTLSVersion;
[string]$url = Join-WebPath -Path $DirectorUrl -ChildPath ([string]::Format('/self-service/ticket?key={0}', $ApiKey)); [string]$url = Join-WebPath -Path $DirectorUrl -ChildPath ([string]::Format('/self-service/ticket?key={0}', $ApiKey));
$response = Invoke-WebRequest -Uri $url -UseBasicParsing -Headers @{ 'accept' = 'application/json'; 'X-Director-Accept' = 'application/json' } -Method 'POST'; $response = Invoke-WebRequest -Uri $url -UseBasicParsing -Headers @{ 'accept' = 'application/json'; 'X-Director-Accept' = 'application/json' } -Method 'POST';

View file

@ -49,6 +49,7 @@ function Register-IcingaDirectorSelfServiceHost()
throw 'Please enter the API key of the template you wish to use'; throw 'Please enter the API key of the template you wish to use';
} }
Set-IcingaTLSVersion;
$ProgressPreference = "SilentlyContinue"; $ProgressPreference = "SilentlyContinue";
$DirectorConfigJson = $null; $DirectorConfigJson = $null;

View file

@ -31,6 +31,7 @@ function Get-IcingaFrameworkServiceBinary()
[string]$ServiceDirectory [string]$ServiceDirectory
); );
Set-IcingaTLSVersion;
$ProgressPreference = "SilentlyContinue"; $ProgressPreference = "SilentlyContinue";
if ([string]::IsNullOrEmpty($FrameworkServiceUrl)) { if ([string]::IsNullOrEmpty($FrameworkServiceUrl)) {

View file

@ -46,6 +46,7 @@ function Get-IcingaPowerShellModuleArchive()
[bool]$DryRun = $FALSE [bool]$DryRun = $FALSE
); );
Set-IcingaTLSVersion;
$ProgressPreference = "SilentlyContinue"; $ProgressPreference = "SilentlyContinue";
$Tag = 'master'; $Tag = 'master';
[bool]$SkipRepo = $FALSE; [bool]$SkipRepo = $FALSE;

View file

@ -51,6 +51,8 @@ function Install-IcingaFrameworkComponent()
throw 'Please specify a component name to install from a GitHub/Local space'; throw 'Please specify a component name to install from a GitHub/Local space';
} }
Set-IcingaTLSVersion;
$TextInfo = (Get-Culture).TextInfo; $TextInfo = (Get-Culture).TextInfo;
$ComponentName = $TextInfo.ToTitleCase($Name); $ComponentName = $TextInfo.ToTitleCase($Name);
$RepositoryName = [string]::Format('icinga-powershell-{0}', $Name); $RepositoryName = [string]::Format('icinga-powershell-{0}', $Name);

View file

@ -14,6 +14,7 @@ function Get-IcingaAgentMSIPackage()
throw 'Please specify a valid download URL, like "https://packages.icinga.com/windows/"'; throw 'Please specify a valid download URL, like "https://packages.icinga.com/windows/"';
} }
Set-IcingaTLSVersion;
# Disable the progress bar for the WebRequest # Disable the progress bar for the WebRequest
$ProgressPreference = "SilentlyContinue"; $ProgressPreference = "SilentlyContinue";
$Architecture = Get-IcingaAgentArchitecture; $Architecture = Get-IcingaAgentArchitecture;

View file

@ -214,6 +214,7 @@ function Copy-IcingaAgentCACertificate()
Copy-Item -Path $CAPath -Destination (Join-Path -Path $Desination -ChildPath 'ca.crt') | Out-Null; Copy-Item -Path $CAPath -Destination (Join-Path -Path $Desination -ChildPath 'ca.crt') | Out-Null;
Write-IcingaConsoleNotice ([string]::Format('Copied ca.crt from "{0}" to "{1}', $CAPath, $Desination)); Write-IcingaConsoleNotice ([string]::Format('Copied ca.crt from "{0}" to "{1}', $CAPath, $Desination));
} else { } else {
Set-IcingaTLSVersion;
# It could also be a web ressource # It could also be a web ressource
try { try {
$response = Invoke-WebRequest $CAPath -UseBasicParsing; $response = Invoke-WebRequest $CAPath -UseBasicParsing;

View file

@ -0,0 +1,4 @@
function Set-IcingaTLSVersion()
{
[Net.ServicePointManager]::SecurityProtocol = "tls12, tls11";
}