2020-03-26 13:08:48 -04:00
|
|
|
function Enable-IcingaUntrustedCertificateValidation()
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
# There is no other way as to use C# for this specific
|
|
|
|
|
# case to configure the certificate validation check
|
2020-08-04 08:48:32 -04:00
|
|
|
Add-Type @"
|
2020-03-26 13:08:48 -04:00
|
|
|
using System.Net;
|
|
|
|
|
using System.Security.Cryptography.X509Certificates;
|
|
|
|
|
|
|
|
|
|
public class IcingaUntrustedCertificateValidation : ICertificatePolicy {
|
|
|
|
|
public bool CheckValidationResult(ServicePoint srvPoint, X509Certificate certificate, WebRequest request, int certificateProblem) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
"@
|
|
|
|
|
|
|
|
|
|
[System.Net.ServicePointManager]::CertificatePolicy = New-Object IcingaUntrustedCertificateValidation;
|
|
|
|
|
|
2020-05-29 08:49:34 -04:00
|
|
|
Write-IcingaConsoleNotice 'Successfully enabled untrusted certificate validation for this shell instance';
|
2020-03-26 13:08:48 -04:00
|
|
|
} catch {
|
2020-05-29 08:49:34 -04:00
|
|
|
Write-IcingaConsoleError -Message 'Failed to enable untrusted certificate policy: {0}' -Objects $_.Exception.Message;
|
2020-03-26 13:08:48 -04:00
|
|
|
}
|
|
|
|
|
}
|