- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to resolve - The underlying connection was closed - Could not
establish trust relationship for the SSL/TLS secure channel in PowerShell?
When you run Invoke-WebRequest or Invoke-RestMethod command, sometimes you get the error “The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.” because there could be a certificate issue or the required windows version doesn’t support the TLS or SSL version. You can use the below command to bypass this error.
[System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true}
Or you can use the below code to resolve this error.
Example
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
- Related Articles
- How to change the TLS version in PowerShell?
- How to resolve - Relative path is not supported in PowerShell DSC?
- How to resolve "Could not find or load main class package" in Java?
- How to get/resolve the command from the alias in PowerShell?
- How To Use Let’s Encrypt SSL Certificate To Secure Nginx for free on CentOS 7
- HTML5 Geolocation without SSL connection
- What is Secure Socket Layer (SSL)?
- How to Resolve DNS address using PowerShell?
- Differentiate between SSL and TSL secure layers
- How to get android notifications when the app was closed?
- How to secure apache with using lets encrypt an open source ssl provider
- How to get website SSL certificate validity dates with PowerShell?
- How to disable “Establishing SSL connection without server's identity verification is not recommended” warning when connecting to MySQL database in Java?
- How to resolve "Expected BEGIN_OBJECT but was BEGIN_ARRAY" using Gson in Java?
- Load placed on server to perform encryption in SAP Secure Network Connection

Advertisements