@lordmilko

This has been working fine for me up until this afternoon. As far as I know nothing has changed. Help please :)

Connect-PrtgServer -Credential $cred -Server $server 
Connect-PrtgServer : The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.
At line:2 char:1
+ Connect-PrtgServer -Credential $cred -Server srhqnms02.scotrailcorp.c ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Connect-PrtgServer], WebException
    + FullyQualifiedErrorId : System.Net.WebException,PrtgAPI.PowerShell.Cmdlets.ConnectPrtgServer

Article Comments

Hi there,

Are you able to manually connect to "srhqnms02.scotrailcorp.com" via HTTPS? It seems that the webserver either uses is using a certificate that is not trusted or that the Webserver of PRTG is not using HTTPS at all.

Best regards.


Apr, 2018 - Permalink

Hi Matthew,

For issues with PrtgAPI you should open an issue on GitHub rather than use Paessler's forums

I think Dariusz is correct; has your certificate expired?

PrtgAPI does not disable the .NET Framework's default SSL validation mechanism, as since PRTG supports both HTTP and HTTPS, there is no reason to configure your PRTG server to use HTTPS unless you actually have a valid certificate.

You will likely find that executing an Invoke-WebRequest command such as

https://prtg.example.com/api/table.xml?content=sensors&columns=objid,name&count=1&username=prtgadmin&password=prtgadmin

will also fail if there are any issues on your PRTG server or your network preventing SSL from working properly

Also, FYI since Server and Credential are positional parameters, you don't need to specify their parameter names

Connect-PrtgServer $server $cred

Regards,

lordmilko


Apr, 2018 - Permalink

At least one thing has changed since it worked fine: time
Is the certificate expired?


Apr, 2018 - Permalink

Hi there,

lordmilko, good to know that you check GitHub issues. I am sure that we can solve this one also here as it might not be linked to underlying code of your great and handy tool!

PRTGToolsFamily, that is true! Maybe the certificate had expired a couple days ago.

Best regards.


Apr, 2018 - Permalink

I'm so sorry for the late reply. I only just saw the responses today - I don't know why I didn't get emails letting me know you all had responded.

We don't have a certificate yet (and never did). I figured out that I had removed a section of code that ignored invalid certificates from my PowerShell profile by accident.

add-type @"
    using System.Net;
    using System.Security.Cryptography.X509Certificates;
    public class TrustAllCertsPolicy : ICertificatePolicy {
        public bool CheckValidationResult(
            ServicePoint srvPoint, X509Certificate certificate,
            WebRequest request, int certificateProblem) {
            return true;
        }
    }
"@
[System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy

All is well now and we are still working on getting a certificate set up.


May, 2018 - Permalink