Fixes client initialising for SSLStream and possible crash reason

This commit is contained in:
Christian Stein 2020-03-24 20:13:28 +01:00
parent 7361fd801b
commit 8d945f3759

View file

@ -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;