From 09e406b90ccfa180ac6a70fb83c8fce28f9932c2 Mon Sep 17 00:00:00 2001 From: LordHepipud Date: Fri, 7 Dec 2018 18:20:04 +0100 Subject: [PATCH] Fix Host FQDN building Fixes #9 to ensure the hostname is always build properly, regardless of Domain, DNS Suffix or Hostname --- core/include/Checker.ps1 | 6 +----- core/include/utils/SSL.ps1 | 6 +----- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/core/include/Checker.ps1 b/core/include/Checker.ps1 index b408c84..97720eb 100644 --- a/core/include/Checker.ps1 +++ b/core/include/Checker.ps1 @@ -17,11 +17,7 @@ $Checker | Add-Member -membertype ScriptMethod -name 'Start' -value { $WindowsInformations = Get-CimInstance Win32_OperatingSystem; $this.version = $WindowsInformations.CimInstanceProperties['Version'].Value; $this.os = $WindowsInformations.CimInstanceProperties['Caption'].Value; - $this.fqdn = [string]::Format( - '{0}.{1}', - (Get-WmiObject Win32_ComputerSystem).DNSHostName, - (Get-WmiObject win32_computersystem).Domain - ); + $this.fqdn = [System.Net.Dns]::GetHostEntry('localhost').HostName; $Icinga2.Log.Write( $Icinga2.Enums.LogState.Info, diff --git a/core/include/utils/SSL.ps1 b/core/include/utils/SSL.ps1 index db32805..3db0349 100644 --- a/core/include/utils/SSL.ps1 +++ b/core/include/utils/SSL.ps1 @@ -24,11 +24,7 @@ $SSL | Add-Member -membertype ScriptMethod -name 'LoadServerCertificate' -value # Try to discover the certificate based on our FQDN if ([string]::IsNullOrEmpty($CertName) -eq $TRUE -And [string]::IsNullOrEmpty($CertThumbprint) -eq $TRUE) { - $CertName = [string]::Format( - '{0}.{1}', - (Get-WmiObject Win32_ComputerSystem).DNSHostName, - (Get-WmiObject win32_computersystem).Domain - ); + $CertName = [System.Net.Dns]::GetHostEntry('localhost').HostName; $Icinga2.Log.Write( $Icinga2.Enums.LogState.Info,