-
-
Notifications
You must be signed in to change notification settings - Fork 32
Description
Expected Behavior
Current Behavior
When trying to create a Netscaler session. I received this error
Invoke-RestMethod : The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.
At C:\Program Files\WindowsPowerShell\Modules\NetScaler\1.7.0\Public\Connect-NetScaler.ps1:115 char:21
-
$response = Invoke-RestMethod @params -
~~~~~~~~~~~~~~~~~~~~~~~~~ - CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
- FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand
Possible Solution
This workaround works, however, I think there are security implications to this but it allowed me to get past the issue.
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
Steps to Reproduce (for bugs)
Use Netscaler generated cert or Self signed cert.
- $Nsip, $Username, $Password = "10.10.10.10", "nsroot", "nsroot"
$SecurePassword = ConvertTo-SecureString $Password -AsPlainText -Force
$Credential = New-Object System.Management.Automation.PSCredential ($Username,
$SecurePassword)
$Session = Connect-Netscaler -Hostname $Nsip -Credential $Credential -https -PassThru
Context
Your Environment
- Module version used: 1.7.0
- Operating System and PowerShell version: Windows 10 1803 and Powershell 5.1