From 8d945f3759b27822ef081e61f95c5208d1b17984 Mon Sep 17 00:00:00 2001 From: Christian Stein Date: Tue, 24 Mar 2020 20:13:28 +0100 Subject: [PATCH] Fixes client initialising for SSLStream and possible crash reason --- lib/web/New-IcingaSSLStream.psm1 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/web/New-IcingaSSLStream.psm1 b/lib/web/New-IcingaSSLStream.psm1 index 6ffc693..556ac12 100644 --- a/lib/web/New-IcingaSSLStream.psm1 +++ b/lib/web/New-IcingaSSLStream.psm1 @@ -1,10 +1,14 @@ function New-IcingaSSLStream() { param( - [System.Net.Sockets.TcpClient]$Client = @{}, + [System.Net.Sockets.TcpClient]$Client = $null, [Security.Cryptography.X509Certificates.X509Certificate2]$Certificate = $null ); + if ($null -eq $Client) { + return $null; + } + $SSLStream = New-Object System.Net.Security.SslStream($Client.GetStream(), $false) $SSLStream.AuthenticateAsServer($Certificate, $false, [System.Security.Authentication.SslProtocols]::Tls12, $true) | Out-Null;