Skip to content

Commit 3ca5f44

Browse files
authored
Merge pull request #147 from Icinga/fix/ssl_error_on_name_change
Fix: SSL creation on reconfigure might fail if naming changed from upper/lower case Fixes an issue while changing the hostname between upper/lower case which might cause unwanted exceptions on one hand but also required manual signing of requests on the CA master as the signing process was not completed
2 parents cc1762b + a5e7e2b commit 3ca5f44

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

doc/31-Changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ Released closed milestones can be found on [GitHub](https://github.com/Icinga/ic
2626
* [#127](https://github.com/Icinga/icinga-powershell-framework/issues/127) Fixes wrong error message on failed MSSQL connection due to database not reachable by using `-IntegratedSecurity`
2727
* [#128](https://github.com/Icinga/icinga-powershell-framework/issues/128) Fixes unhandled output from loading `System.Reflection.Assembly` which can cause weird side effects for plugin outputs
2828
* [#130](https://github.com/Icinga/icinga-powershell-framework/issues/130) Fix crash while running services as background task to collect metrics over time by missing Performance Counter cache initialisation
29+
* [#133](https://github.com/Icinga/icinga-powershell-framework/issues/133), [#147](https://github.com/Icinga/icinga-powershell-framework/pull/147) Fixes an issue while changing the hostname between upper/lower case which might cause unwanted exceptions on one hand but also required manual signing of requests on the CA master as the signing process was not completed
2930
* [#138](https://github.com/Icinga/icinga-powershell-framework/issues/138) Fixes possible value overflow on `Convert-Bytes` while converting from anything larger than MB to Bytes
3031
* [#140](https://github.com/Icinga/icinga-powershell-framework/issues/140) Fixes version fetching for not loaded modules during upgrades/plugin calls with `Get-IcingaPowerShellModuleVersion`
3132
* [#143](https://github.com/Icinga/icinga-powershell-framework/issues/143) Fixes the annoying hint from the analyzer to check space before open brace

lib/core/icingaagent/installer/Install-IcingaAgentCertificates.psm1

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ function Install-IcingaAgentCertificates()
8282
Write-IcingaConsoleError 'Failed to generate host certificate';
8383
return $FALSE;
8484
}
85+
86+
# Once we generated new host certificates, we always require to sign them if possible
87+
$Force = $TRUE;
8588
}
8689

8790
if ([string]::IsNullOrEmpty($Endpoint) -And [string]::IsNullOrEmpty($CACert)) {
@@ -226,8 +229,9 @@ function Test-IcingaAgentCertificates()
226229
return $FALSE;
227230
}
228231

229-
[string]$hostCRT = [string]::Format('{0}.crt', $Hostname);
230-
[string]$hostKEY = [string]::Format('{0}.key', $Hostname);
232+
[string]$hostCRT = [string]::Format('{0}.crt', $Hostname);
233+
[string]$hostKEY = [string]::Format('{0}.key', $Hostname);
234+
[bool]$CertNameInvalid = $FALSE;
231235

232236
$certificates = Get-ChildItem -Path $CertDirectory;
233237
# Now loop each file and match their name with our hostname
@@ -236,11 +240,18 @@ function Test-IcingaAgentCertificates()
236240
$file = $cert.Name.Replace('.key', '').Replace('.crt', '');
237241
if (-Not ($file -clike $Hostname)) {
238242
Write-IcingaConsoleWarning ([string]::Format('Certificate file {0} is not matching the hostname {1}. Certificate generation is required.', $cert.Name, $Hostname));
239-
return $FALSE;
243+
$CertNameInvalid = $TRUE;
244+
break;
240245
}
241246
}
242247
}
243248

249+
if ($CertNameInvalid) {
250+
Remove-Item -Path (Join-Path -Path $CertDirectory -ChildPath $hostCRT) -Force;
251+
Remove-Item -Path (Join-Path -Path $CertDirectory -ChildPath $hostKEY) -Force;
252+
return $FALSE;
253+
}
254+
244255
Write-IcingaConsoleNotice 'Icinga host certificates are present and valid. No generation required';
245256

246257
return $TRUE;

0 commit comments

Comments
 (0)