diff --git a/contrib/win32/openssh/GetLibreSSL.ps1 b/contrib/win32/openssh/GetLibreSSL.ps1
new file mode 100644
index 000000000..8a51a575a
--- /dev/null
+++ b/contrib/win32/openssh/GetLibreSSL.ps1
@@ -0,0 +1,55 @@
+param (
+ [string]$sourceUrl = "https://github.com/PowerShell/libressl/releases/latest/",
+ [string]$zipDir,
+ [string]$destDir,
+ [switch]$override
+ )
+
+If ($PSVersiontable.PSVersion.Major -le 2) {$PSScriptRoot = Split-Path -Parent $MyInvocation.MyCommand.Path}
+# Workaround that $PSScriptRoot is not support on ps version 2
+if([string]::IsNullOrEmpty($zipDir))
+{
+ $zipDir = $PSScriptRoot
+}
+
+if([string]::IsNullOrEmpty($destDir))
+{
+ $destDir = $PSScriptRoot
+}
+
+if($override)
+{
+ Remove-Item (join-path $destDir "LibreSSL") -Recurse -Force -ErrorAction SilentlyContinue
+}
+elseif (Test-Path (Join-Path $destDir "LibreSSL") -PathType Container)
+{
+ return
+}
+
+[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 -bor `
+ [Net.SecurityProtocolType]::Tls11 -bor `
+ [Net.SecurityProtocolType]::Tls
+
+ $request = [System.Net.WebRequest]::Create($sourceUrl)
+ $request.AllowAutoRedirect = $false
+ $request.Timeout = 60000; # 1 mins for the download to complete
+ $response = $request.GetResponse()
+ $release_url = $([String]$response.GetResponseHeader("Location")).Replace('tag','download') + '/LibreSSL.zip'
+ $zip_path = Join-Path $zipDir "libressl.zip"
+
+ # Download libressl latest release binaries
+ Remove-Item $zip_path -Force -ErrorAction SilentlyContinue
+ (New-Object System.Net.WebClient).DownloadFile($release_url, $zip_path)
+ if(-not (Test-Path $zip_path))
+ {
+ throw "failed to download ssl zip file"
+ }
+
+ # Expand the zip file
+ Expand-Archive -Path $zip_path -DestinationPath $destDir -Force -ErrorAction SilentlyContinue -ErrorVariable e
+ if($e -ne $null)
+ {
+ throw "Error when expand zip file"
+ }
+
+ Remove-Item $zip_path -Force -ErrorAction SilentlyContinue
\ No newline at end of file
diff --git a/contrib/win32/openssh/OpenSSHBuildHelper.psm1 b/contrib/win32/openssh/OpenSSHBuildHelper.psm1
index a77ad5715..59b2fa569 100644
--- a/contrib/win32/openssh/OpenSSHBuildHelper.psm1
+++ b/contrib/win32/openssh/OpenSSHBuildHelper.psm1
@@ -690,9 +690,13 @@ function Get-BuildLogFile
[ValidateSet('Debug', 'Release')]
[string]$Configuration = "Release"
-
- )
- return Join-Path -Path $root -ChildPath "contrib\win32\openssh\OpenSSH$($Configuration)$($NativeHostArch).log"
+ )
+ if($root -ieq $PSScriptRoot)
+ {
+ return Join-Path -Path $PSScriptRoot -ChildPath "OpenSSH$($Configuration)$($NativeHostArch).log"
+ } else {
+ return Join-Path -Path $root -ChildPath "contrib\win32\openssh\OpenSSH$($Configuration)$($NativeHostArch).log"
+ }
}
function Get-SolutionFile
@@ -701,9 +705,14 @@ function Get-SolutionFile
(
[Parameter(Mandatory=$true)]
[ValidateNotNull()]
- [System.IO.DirectoryInfo] $root
+ [System.IO.DirectoryInfo] $root
)
- return Join-Path -Path $root -ChildPath "contrib\win32\openssh\Win32-OpenSSH.sln"
+ if($root -ieq $PSScriptRoot)
+ {
+ return Join-Path -Path $PSScriptRoot -ChildPath "Win32-OpenSSH.sln"
+ } else {
+ return Join-Path -Path $root -ChildPath "contrib\win32\openssh\Win32-OpenSSH.sln"
+ }
}
diff --git a/contrib/win32/openssh/config.vcxproj b/contrib/win32/openssh/config.vcxproj
index ca5500fee..717c09b78 100644
--- a/contrib/win32/openssh/config.vcxproj
+++ b/contrib/win32/openssh/config.vcxproj
@@ -186,10 +186,11 @@
$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(LibreSSL-x86-Path);%(AdditionalLibraryDirectories)
- powershell.exe -Executionpolicy Bypass -File "$(SolutionDir)config.ps1" -Config_h_vs "$(SolutionDir)config.h.vs" -Config_h "$(OpenSSH-Src-Path)config.h" -VCIncludePath "$(VC_IncludePath)" -OutCRTHeader "$(OpenSSH-Src-Path)contrib\win32\win32compat\inc\crtheaders.h"
+ powershell.exe -Executionpolicy Bypass -File "$(SolutionDir)config.ps1" -Config_h_vs "$(SolutionDir)config.h.vs" -Config_h "$(OpenSSH-Src-Path)config.h" -VCIncludePath "$(VC_IncludePath)" -OutCRTHeader "$(OpenSSH-Src-Path)contrib\win32\win32compat\inc\crtheaders.h"
+powershell.exe -Executionpolicy Bypass -File "$(SolutionDir)GetLibreSSL.ps1"
- Generate crtheaders.h and config.h
+ Generate crtheaders.h and config.h; fetch libressl sdk
copy /Y "$(SolutionDir)install-ssh*ps1" "$(OutDir)"
@@ -219,10 +220,11 @@ copy /Y "$(SolutionDir)openssh-events.man" "$(OutDir)"
$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(LibreSSL-x64-Path);%(AdditionalLibraryDirectories)
- powershell.exe -Executionpolicy Bypass -File "$(SolutionDir)config.ps1" -Config_h_vs "$(SolutionDir)config.h.vs" -Config_h "$(OpenSSH-Src-Path)config.h" -VCIncludePath "$(VC_IncludePath)" -OutCRTHeader "$(OpenSSH-Src-Path)contrib\win32\win32compat\inc\crtheaders.h"
+ powershell.exe -Executionpolicy Bypass -File "$(SolutionDir)config.ps1" -Config_h_vs "$(SolutionDir)config.h.vs" -Config_h "$(OpenSSH-Src-Path)config.h" -VCIncludePath "$(VC_IncludePath)" -OutCRTHeader "$(OpenSSH-Src-Path)contrib\win32\win32compat\inc\crtheaders.h"
+powershell.exe -Executionpolicy Bypass -File "$(SolutionDir)GetLibreSSL.ps1"
- Generate crtheaders.h and config.h
+ Generate crtheaders.h and config.h; fetch libressl sdk
copy /Y "$(SolutionDir)install-ssh*ps1" "$(OutDir)"
@@ -252,10 +254,11 @@ copy /Y "$(SolutionDir)openssh-events.man" "$(OutDir)"
$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(LibreSSL-arm64-Path);%(AdditionalLibraryDirectories)
- powershell.exe -Executionpolicy Bypass -File "$(SolutionDir)config.ps1" -Config_h_vs "$(SolutionDir)config.h.vs" -Config_h "$(OpenSSH-Src-Path)config.h" -VCIncludePath "$(VC_IncludePath)" -OutCRTHeader "$(OpenSSH-Src-Path)contrib\win32\win32compat\inc\crtheaders.h"
+ powershell.exe -Executionpolicy Bypass -File "$(SolutionDir)config.ps1" -Config_h_vs "$(SolutionDir)config.h.vs" -Config_h "$(OpenSSH-Src-Path)config.h" -VCIncludePath "$(VC_IncludePath)" -OutCRTHeader "$(OpenSSH-Src-Path)contrib\win32\win32compat\inc\crtheaders.h"
+powershell.exe -Executionpolicy Bypass -File "$(SolutionDir)GetLibreSSL.ps1"
- Generate crtheaders.h and config.h
+ Generate crtheaders.h and config.h; fetch libressl sdk
copy /Y "$(SolutionDir)install-ssh*ps1" "$(OutDir)"
@@ -285,10 +288,11 @@ copy /Y "$(SolutionDir)openssh-events.man" "$(OutDir)"
$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(LibreSSL-arm-Path);%(AdditionalLibraryDirectories)
- powershell.exe -Executionpolicy Bypass -File "$(SolutionDir)config.ps1" -Config_h_vs "$(SolutionDir)config.h.vs" -Config_h "$(OpenSSH-Src-Path)config.h" -VCIncludePath "$(VC_IncludePath)" -OutCRTHeader "$(OpenSSH-Src-Path)contrib\win32\win32compat\inc\crtheaders.h"
+ powershell.exe -Executionpolicy Bypass -File "$(SolutionDir)config.ps1" -Config_h_vs "$(SolutionDir)config.h.vs" -Config_h "$(OpenSSH-Src-Path)config.h" -VCIncludePath "$(VC_IncludePath)" -OutCRTHeader "$(OpenSSH-Src-Path)contrib\win32\win32compat\inc\crtheaders.h"
+powershell.exe -Executionpolicy Bypass -File "$(SolutionDir)GetLibreSSL.ps1"
- Generate crtheaders.h and config.h
+ Generate crtheaders.h and config.h; fetch libressl sdk
copy /Y "$(SolutionDir)install-ssh*ps1" "$(OutDir)"
@@ -322,10 +326,11 @@ copy /Y "$(SolutionDir)openssh-events.man" "$(OutDir)"
$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(LibreSSL-x86-Path);%(AdditionalLibraryDirectories)
- powershell.exe -Executionpolicy Bypass -File "$(SolutionDir)config.ps1" -Config_h_vs "$(SolutionDir)config.h.vs" -Config_h "$(OpenSSH-Src-Path)config.h" -VCIncludePath "$(VC_IncludePath)" -OutCRTHeader "$(OpenSSH-Src-Path)contrib\win32\win32compat\inc\crtheaders.h"
+ powershell.exe -Executionpolicy Bypass -File "$(SolutionDir)config.ps1" -Config_h_vs "$(SolutionDir)config.h.vs" -Config_h "$(OpenSSH-Src-Path)config.h" -VCIncludePath "$(VC_IncludePath)" -OutCRTHeader "$(OpenSSH-Src-Path)contrib\win32\win32compat\inc\crtheaders.h"
+powershell.exe -Executionpolicy Bypass -File "$(SolutionDir)GetLibreSSL.ps1"
- Generate crtheaders.h and config.h
+ Generate crtheaders.h and config.h; fetch libressl sdk
copy /Y "$(SolutionDir)install-ssh*ps1" "$(OutDir)"
@@ -359,10 +364,11 @@ copy /Y "$(SolutionDir)openssh-events.man" "$(OutDir)"
$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(LibreSSL-x64-Path);%(AdditionalLibraryDirectories)
- powershell.exe -Executionpolicy Bypass -File "$(SolutionDir)config.ps1" -Config_h_vs "$(SolutionDir)config.h.vs" -Config_h "$(OpenSSH-Src-Path)config.h" -VCIncludePath "$(VC_IncludePath)" -OutCRTHeader "$(OpenSSH-Src-Path)contrib\win32\win32compat\inc\crtheaders.h"
+ powershell.exe -Executionpolicy Bypass -File "$(SolutionDir)config.ps1" -Config_h_vs "$(SolutionDir)config.h.vs" -Config_h "$(OpenSSH-Src-Path)config.h" -VCIncludePath "$(VC_IncludePath)" -OutCRTHeader "$(OpenSSH-Src-Path)contrib\win32\win32compat\inc\crtheaders.h"
+powershell.exe -Executionpolicy Bypass -File "$(SolutionDir)GetLibreSSL.ps1"
- Generate crtheaders.h and config.h
+ Generate crtheaders.h and config.h; fetch libressl sdk
copy /Y "$(SolutionDir)install-ssh*ps1" "$(OutDir)"
@@ -396,10 +402,11 @@ copy /Y "$(SolutionDir)openssh-events.man" "$(OutDir)"
$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(LibreSSL-arm64-Path);%(AdditionalLibraryDirectories)
- powershell.exe -Executionpolicy Bypass -File "$(SolutionDir)config.ps1" -Config_h_vs "$(SolutionDir)config.h.vs" -Config_h "$(OpenSSH-Src-Path)config.h" -VCIncludePath "$(VC_IncludePath)" -OutCRTHeader "$(OpenSSH-Src-Path)contrib\win32\win32compat\inc\crtheaders.h"
+ powershell.exe -Executionpolicy Bypass -File "$(SolutionDir)config.ps1" -Config_h_vs "$(SolutionDir)config.h.vs" -Config_h "$(OpenSSH-Src-Path)config.h" -VCIncludePath "$(VC_IncludePath)" -OutCRTHeader "$(OpenSSH-Src-Path)contrib\win32\win32compat\inc\crtheaders.h"
+powershell.exe -Executionpolicy Bypass -File "$(SolutionDir)GetLibreSSL.ps1"
- Generate crtheaders.h and config.h
+ Generate crtheaders.h and config.h; fetch libressl sdk
copy /Y "$(SolutionDir)install-ssh*ps1" "$(OutDir)"
@@ -433,10 +440,11 @@ copy /Y "$(SolutionDir)openssh-events.man" "$(OutDir)"
$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(LibreSSL-arm-Path);%(AdditionalLibraryDirectories)
- powershell.exe -Executionpolicy Bypass -File "$(SolutionDir)config.ps1" -Config_h_vs "$(SolutionDir)config.h.vs" -Config_h "$(OpenSSH-Src-Path)config.h" -VCIncludePath "$(VC_IncludePath)" -OutCRTHeader "$(OpenSSH-Src-Path)contrib\win32\win32compat\inc\crtheaders.h"
+ powershell.exe -Executionpolicy Bypass -File "$(SolutionDir)config.ps1" -Config_h_vs "$(SolutionDir)config.h.vs" -Config_h "$(OpenSSH-Src-Path)config.h" -VCIncludePath "$(VC_IncludePath)" -OutCRTHeader "$(OpenSSH-Src-Path)contrib\win32\win32compat\inc\crtheaders.h"
+powershell.exe -Executionpolicy Bypass -File "$(SolutionDir)GetLibreSSL.ps1"
- Generate crtheaders.h and config.h
+ Generate crtheaders.h and config.h; fetch libressl sdk
copy /Y "$(SolutionDir)install-ssh*ps1" "$(OutDir)"