passff-host
passff-host copied to clipboard
set tls12 before downloading, otherwise download failed with:
Ausnahme beim Aufrufen von "DownloadFile" mit 2 Argument(en): "Die Anfrage wurde abgebrochen: Es konnte kein
geschützter SSL/TLS-Kanal erstellt werden.."
In Zeile:1 Zeichen:1
+ (New-Object Net.WebClient).DownloadFile('https://github.com/passff/pa ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : WebException
Where the German error message translates to:
Exception calling "DownloadFile" with "2" argument(s): "The request was aborted: Could not create SSL/TLS secure channel."
Many thanks for the great passff plugin! :)
Thanks for the pull request!
I have literally no knowledge about PowerShell, but I have tested the old and new command lines anyway. Your patch basically adds a second command to create a TLS tunnel I guess.
PS C:\Users\5bentz> (New-Object Net.WebClient).DownloadFile('https://github.com/passff/passff-host/releases/download/1.0.1/passff.py', 'thefile.py')
PS C:\Users\5bentz> [Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12; (New-Object Net.WebClient).DownloadFile('https://github.com/passff/passff-host/releases/download/1.0.1/passff.py', 'thefile.py')
- Both command lines (old and new) work on my Windows 10 Pro (Updated 29/03/2018): the file is downloaded
- None work on my Windows 7 Home (Up to date), which is sad
The errors of your line. It seems that both commands failed.
Exception lors de la définition de « SecurityProtocol » : « Impossible de convertir la valeur Null en type « System.Net.SecurityProtocolType » en raison de valeurs d'énumération non valides.
Spécifiez l'une des valeurs d'énumération suivantes et réessayez. Les valeurs d'énumération possibles sont « Ssl3, Tls ». »
Au niveau de ligne : 1 Caractère : 28
+ [Net.ServicePointManager]:: <<<< SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12; (New-Object Net.WebClient).DownloadFile('https://github.com/passff/passff-host/releases/download/1.0.1/passff.py', 'thefile.py')
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : PropertyAssignmentException
Exception lors de l'appel de « DownloadFile » avec « 2 » argument(s) : « La connexion sous-jacente a été fermée : Une erreur inattendue s'est produite lors de l'envoi. »
Au niveau de ligne : 1 Caractère : 128
+ [Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12; (New-Object Net.WebClient).DownloadFile <<<< ('https://github.com/passff/passff-host/releases/download/1.0.1/passff.py', 'thefile.py')
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodException
Using Tls
instead of Tls12
somewhat fixes the first error.
Strangely enough, (New-Object Net.WebClient).DownloadFile('https://example.com', 'kappa')
works. But with https://github.com
, it does not.
PS C:\Users\5bentz> [Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls; (New-Object Net.WebClient).DownloadFile('https://example.com', 'keepo')
works too...
Sorry for the late reply, I've been doing the PR on Windows 10, up to date at the time doing it. I've not tested it on Windows 7 or re-verified.
It's hard to say what exactly causes/resolves the problem. Seems to affect other users on Win10 as well, but beeing hard to reproduce/solve for all versions.
As I also have barely any PowerShell experience I cannot add good ideas or enhancements to this PR. Suggest to either close it, or wait for someone with more knowledge on PS to jump in.
Sorry it has been a long time. I don't know why, but I forgot to report my conclusion x( After additional testing, the issue with Win7 is pristine clear: TLS.
Below the command lines I tested:
- GitHub without and with your fix.
- Example.com without and with your fix.
$your_user="Your_user_here"
#github, old, new
(New-Object Net.WebClient).DownloadFile("https://github.com/passff/passff-host/releases/download/1.0.2/passff.py", "C:\Users\$your_user\passff_test.py")
[Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12; (New-Object Net.WebClient).DownloadFile("https://github.com/passff/passff-host/releases/download/1.0.2/passff.py", "C:\Users\$your_user\passff_test.py")
#example.com, old, new
(New-Object Net.WebClient).DownloadFile("http://example.com", "C:\Users\$your_user\passff_test.py")
[Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12; (New-Object Net.WebClient).DownloadFile("http://example.com", "C:\Users\$your_user\passff_test.py")
All commands work on Windows 10's PowerShell and on PowerShell 6 for Win7. Github does not work on Win7's PowerShell. Example.com works on Win7 (with Tls instead of Tls12).
Again, the culprit is the TLS handshake: Win7's powershell does understand only SSLv3 or TLS1.0, while GitHub supports only TLSv1.2. Thus Win7's powershell fails to connect to GitHub ;3 (Thanks Wireshark !).
Hopefully, there is a workaround on Windows 7: installing the version 6 of PowerShell from GitHub or with chocolatey!
The issue, that some Win10 users have, might also be related to a failure in the TLS handshake...
Currently not using any Windows machine, therefore I'm not able to follow up on the details here.