mirror of
https://github.com/andrey271192/ssh-manage.git
synced 2026-09-21 12:02:01 +00:00
fix: Windows download — TLS12 + WebClient fallback
Invoke-WebRequest fails without TLS12 on some Windows. Use System.Net.WebClient with explicit TLS12 and User-Agent. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -74,6 +74,9 @@ New-Item -ItemType Directory -Path $localDir | Out-Null
|
||||
$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
|
||||
if (-not $scriptDir) { $scriptDir = Get-Location }
|
||||
|
||||
# Ensure TLS 1.2 for GitHub downloads
|
||||
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
|
||||
|
||||
$filesToGet = @("ssh_manager.py", "gen_icon.py")
|
||||
foreach ($f in $filesToGet) {
|
||||
$localFile = Join-Path $scriptDir $f
|
||||
@@ -84,10 +87,20 @@ foreach ($f in $filesToGet) {
|
||||
} else {
|
||||
Write-Host "[*] Downloading $f from GitHub..." -ForegroundColor Yellow
|
||||
try {
|
||||
Invoke-WebRequest -Uri "$REPO_RAW/$f" -OutFile $destFile -UseBasicParsing
|
||||
Write-Host "[OK] $f (downloaded)" -ForegroundColor Green
|
||||
$url = "$REPO_RAW/$f"
|
||||
Write-Host " URL: $url" -ForegroundColor DarkGray
|
||||
$wc = New-Object System.Net.WebClient
|
||||
$wc.Headers.Add("User-Agent", "PCA-SSH-Installer")
|
||||
$wc.DownloadFile($url, $destFile)
|
||||
if (Test-Path $destFile) {
|
||||
$sz = (Get-Item $destFile).Length
|
||||
Write-Host "[OK] $f ($sz bytes)" -ForegroundColor Green
|
||||
} else {
|
||||
throw "File not saved"
|
||||
}
|
||||
} catch {
|
||||
Write-Host "[FAIL] Cannot download $f" -ForegroundColor Red
|
||||
Write-Host "[FAIL] Cannot download $f : $_" -ForegroundColor Red
|
||||
Write-Host "Try manual download: https://github.com/andrey271192/ssh-manage" -ForegroundColor Yellow
|
||||
Read-Host "Press Enter"
|
||||
exit 1
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user