Borbin the 🐱

use TLS1.2

24 February, 2018


If you found that your code to download from a website started failing with an error like:

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

or

Ausnahme beim Aufrufen von "DownloadFile" mit 2 Argument(en):  "Die Anfrage wurde abgebrochen: Es konnte kein 
geschützter SSL/TLS-Kanal erstellt werden."
+ $webclient.DownloadFile($file, $toZipFile)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : WebException

then your webserver security is updated and now requires TLS1.2.
Tls is a security protocol to transfer data over the Internet. To solve this issue, simply set the security protocol to Tls1.2.

For example in PowerShell:

$webclient = New-Object System.Net.WebClient
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$webclient.DownloadFile($file, $toZipFile)