From 4f8b51ce7894341cca977b0909c1e5a70833c2ce Mon Sep 17 00:00:00 2001 From: Lord Hepipud Date: Tue, 28 Apr 2020 13:48:15 +0200 Subject: [PATCH] Handle deprecated argument --key for Icinga Agent save-cert cmd Fixes #62 --- .../Install-IcingaAgentCertificates.psm1 | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/lib/core/icingaagent/installer/Install-IcingaAgentCertificates.psm1 b/lib/core/icingaagent/installer/Install-IcingaAgentCertificates.psm1 index eeb16c5..71699de 100644 --- a/lib/core/icingaagent/installer/Install-IcingaAgentCertificates.psm1 +++ b/lib/core/icingaagent/installer/Install-IcingaAgentCertificates.psm1 @@ -48,11 +48,19 @@ function Install-IcingaAgentCertificates() Write-Host ([string]::Format('Fetching trusted master certificate from "{0}"', $Endpoint)); - $arguments = [string]::Format('pki save-cert --key {0}{1}.key --trustedcert {0}trusted-parent.crt --host {2}', - $CertificateDirectory, - $Hostname, - $Endpoint - ); + # Argument --key for save-cert is deprecated starting with Icinga 2.12.0 + if (Compare-IcingaVersions -RequiredVersion '2.12.0') { + $arguments = [string]::Format('pki save-cert --trustedcert {0}trusted-parent.crt --host {1}', + $CertificateDirectory, + $Endpoint + ); + } else { + $arguments = [string]::Format('pki save-cert --key {0}{1}.key --trustedcert {0}trusted-parent.crt --host {2}', + $CertificateDirectory, + $Hostname, + $Endpoint + ); + } if ((Start-IcingaAgentCertificateProcess -Arguments $arguments) -eq $FALSE) { Write-Host 'Unable to connect to your provided Icinga CA. Please verify the entered configuration is correct.' `