Open sandersjds opened 10 years ago
Could you please take a look at adding the ability to ignore bad ssl certs?
this function tends to work for me ...
function Ignore-SSLCertificates { $Provider = New-Object Microsoft.CSharp.CSharpCodeProvider $Compiler = $Provider.CreateCompiler() $Params = New-Object System.CodeDom.Compiler.CompilerParameters $Params.GenerateExecutable = $false $Params.GenerateInMemory = $true $Params.IncludeDebugInformation = $false $Params.ReferencedAssemblies.Add("System.DLL") > $null $TASource=@' namespace Local.ToolkitExtensions.Net.CertificatePolicy { public class TrustAll : System.Net.ICertificatePolicy { public bool CheckValidationResult(System.Net.ServicePoint sp,System.Security.Cryptography.X509Certificates.X509Certificate cert, System.Net.WebRequest req, int problem) { return true; } } } '@ $TAResults=$Provider.CompileAssemblyFromSource($Params,$TASource) $TAAssembly=$TAResults.CompiledAssembly
$TrustAll = $TAAssembly.CreateInstance("Local.ToolkitExtensions.Net.CertificatePolicy.TrustAll")
[System.Net.ServicePointManager]::CertificatePolicy = $TrustAll
} Ignore-SSLCertificates
could you please try to integrate this into the module? (the place I work uses prtg with a self signed ssl cert, and I can not get your module to work for me due to ssl issues.
Can look at possibly integrating this code, but we already have some handlers in place to allow self-signed certs.
What version of PRTG are you running? Is it the one after they added all the new SSL security (14.4.12, I think)?
The latest version of PRTG introduces some new security settings that I believe move the default encryption beyond the capabilities of powershell's webclient. You can test this by switching the new stuff off in PRTG (Setup -> System Administration -> User Interface -> SSL Security -> "Weakened Security").
version is PRTG Network Monitor 14.4.12.3410 x64 .... I can however connect via "Invoke-WebRequest -Method get -Uri "$apiendpoint/table.xml?content=sensors$authenticationstring" .... but only after setting the session to ignore ssl via the function I posted, ive tried to edit your module to include the function, but I cant seem to get it to work right, anyways, if you could get it to work your module would be super helpful for some things I am working on.
Should return something useful if the connection doesn't succeed, rather than a generic powershell error message.