Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get-PrtgServer needs proper error handling #5

Open
sandersjds opened this issue Feb 4, 2014 · 3 comments
Open

Get-PrtgServer needs proper error handling #5

sandersjds opened this issue Feb 4, 2014 · 3 comments
Assignees

Comments

@sandersjds
Copy link
Collaborator

Should return something useful if the connection doesn't succeed, rather than a generic powershell error message.

@sandersjds sandersjds self-assigned this Feb 4, 2014
@chreestopher
Copy link

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
## We create an instance of TrustAll and attach it to the ServicePointManager
$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.

@sandersjds
Copy link
Collaborator Author

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").

@chreestopher
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants