当前位置:网站首页>The request was aborted: Could not create SSL/TLS secure channel.

The request was aborted: Could not create SSL/TLS secure channel.

2022-06-24 03:26:00 shawyang

invoke-webrequest One url An error occurs when getting a file invoke-webrequest : The request was aborted: Could not create SSL/TLS secure channel.

invoke-webrequest "http://www.7-zip.org/a/7z1900-x64.msi" -outfile "c:\7z1900.msi"

【 Temporary solutions 】

powershell perform

[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

【 Radical approach 】

Through the registry to achieve , Save the following code as tls1.2_on.reg, Double click the point “ yes ” After import , And on again powershell perform [Net.ServicePointManager]::SecurityProtocol Will show SystemDefault, In this way, it will be closed later powershell There will be no problem opening it

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\v4.0.30319]

"SystemDefaultTlsVersions"=dword:00000001

[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\.NETFramework\v4.0.30319]

"SystemDefaultTlsVersions"=dword:00000001

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\v2.0.50727]

"SystemDefaultTlsVersions"=dword:00000001

[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\.NETFramework\v2.0.50727]

"SystemDefaultTlsVersions"=dword:00000001

【 process analysis 】

server2016 On the system powershell An error is reported when you execute this command The request was aborted: Could not create SSL/TLS secure channel.

invoke-webrequest "http://www.7-zip.org/a/7z1900-x64.msi" -outfile "c:\7z1900.msi"

server 2016 powershell function [Net.ServicePointManager]::SecurityProtocol Check to see if Tls12.

at present Tls12(tls1.2,powershell If enabled , Will be displayed Tls12) It's mainstream ,IE Browsers do not support less than Tls12 Of https Visited , Access some directly without modification URL Will be submitted to the SSL/TLS dependent error msg.

server 2016 It needs to be transformed in the following way ,server 2019 Of powershell Default already tls1.2, No need to change .

https://docs.microsoft.com/zh-cn/powershell/module/powershellget/?view=powershell-7

As of April 2020, the PowerShell Gallery no longer supports Transport Layer Security (TLS) versions 1.0 and 1.1. If you are not using TLS 1.2 or higher, you will receive an error when trying to access the PowerShell Gallery. Use the following command to ensure you are using TLS 1.2:

[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

For more information, see the announcement in the PowerShell blog.

powershell Internal execution [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 Just a temporary measure , close powershell Open it next time powershell It's still old Ssl3, Tls. The permanent solution is through the registry , As stated above .

It's solved tls1.2 And then visit invoke-webrequest "http://www.7-zip.org/a/7z1900-x64.msi" -outfile "c:\7z1900.msi" I won't make a mistake , success get To the file .

原网站

版权声明
本文为[shawyang]所创,转载请带上原文链接,感谢
https://yzsam.com/2021/10/20211008231734893f.html

随机推荐