mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-06-28 11:10:21 -07:00
move the TLS detection block of win_uri before creating WebRequest (#43168)
* move the TLS detection block of win_url before creating WebRequest * fix typo security_protocols
This commit is contained in:
parent
547f11ad8f
commit
7fedda4c1d
1 changed files with 10 additions and 11 deletions
|
@ -67,6 +67,16 @@ if ($status_code) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Enable TLS1.1/TLS1.2 if they're available but disabled (eg. .NET 4.5)
|
||||||
|
$security_protocols = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::SystemDefault
|
||||||
|
if ([Net.SecurityProtocolType].GetMember("Tls11").Count -gt 0) {
|
||||||
|
$security_protocols = $security_protocols -bor [Net.SecurityProtocolType]::Tls11
|
||||||
|
}
|
||||||
|
if ([Net.SecurityProtocolType].GetMember("Tls12").Count -gt 0) {
|
||||||
|
$security_protocols = $security_protocols -bor [Net.SecurityProtocolType]::Tls12
|
||||||
|
}
|
||||||
|
[Net.ServicePointManager]::SecurityProtocol = $security_protocols
|
||||||
|
|
||||||
$client = [System.Net.WebRequest]::Create($url)
|
$client = [System.Net.WebRequest]::Create($url)
|
||||||
$client.Method = $method
|
$client.Method = $method
|
||||||
$client.Timeout = $timeout * 1000
|
$client.Timeout = $timeout * 1000
|
||||||
|
@ -98,17 +108,6 @@ if (-not $validate_certs) {
|
||||||
[System.Net.ServicePointManager]::ServerCertificateValidationCallback = { $true }
|
[System.Net.ServicePointManager]::ServerCertificateValidationCallback = { $true }
|
||||||
}
|
}
|
||||||
|
|
||||||
# Enable TLS1.1/TLS1.2 if they're available but disabled (eg. .NET 4.5)
|
|
||||||
$security_protcols = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::SystemDefault
|
|
||||||
if ([Net.SecurityProtocolType].GetMember("Tls11").Count -gt 0) {
|
|
||||||
$security_protcols = $security_protcols -bor [Net.SecurityProtocolType]::Tls11
|
|
||||||
}
|
|
||||||
if ([Net.SecurityProtocolType].GetMember("Tls12").Count -gt 0) {
|
|
||||||
$security_protcols = $security_protcols -bor [Net.SecurityProtocolType]::Tls12
|
|
||||||
}
|
|
||||||
[Net.ServicePointManager]::SecurityProtocol = $security_protcols
|
|
||||||
|
|
||||||
|
|
||||||
if ($null -ne $content_type) {
|
if ($null -ne $content_type) {
|
||||||
$client.ContentType = $content_type
|
$client.ContentType = $content_type
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue