Skip to content

Commit

Permalink
Merge pull request #31 from mlocati/SchUseStrongCrypto-registry-key
Browse files Browse the repository at this point in the history
Check (and set) the SchUseStrongCrypto registry key
  • Loading branch information
mlocati authored May 17, 2019
2 parents 3155641 + 2510967 commit 4710f24
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
2 changes: 1 addition & 1 deletion PhpManager/private/Get-FileFromUrlOrCache.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
try {
Set-NetSecurityProtocolType
Write-Verbose "Downloading from $Url"
Invoke-WebRequest -UseBasicParsing $Url -OutFile $temporaryFile
Invoke-WebRequest -UseBasicParsing -Uri $Url -OutFile $temporaryFile
if ($fullCachePath -ne '') {
Move-Item -LiteralPath $temporaryFile -Destination $fullCachePath
$localFile = $fullCachePath
Expand Down
26 changes: 25 additions & 1 deletion PhpManager/private/Set-NetSecurityProtocolType.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,34 @@
begin {
}
process {
$regValueName = 'SchUseStrongCrypto'
try {
$netVersion = [System.Environment].Assembly.ImageRuntimeVersion
$regKeyPath = "HKLM:\SOFTWARE\Microsoft\.NETFramework\$netVersion"
if (Test-Path -LiteralPath $regKeyPath) {
$regKey = Get-Item -LiteralPath $regKeyPath
if (-Not($regKey.GetValue($regValueName))) {
Write-Verbose "Setting the $regValueName registry key"
Set-ItemProperty -LiteralPath $regKeyPath -Name $regValueName -Value 1
}
$regKeyPath = "HKLM:\SOFTWARE\WOW6432Node\Microsoft\.NETFramework\$netVersion"
if (Test-Path -LiteralPath $regKeyPath) {
$regKey = Get-Item -LiteralPath $regKeyPath
if (-Not($regKey.GetValue($regValueName))) {
Write-Verbose "Setting the $regValueName registry key for WOW64"
Set-ItemProperty -LiteralPath $regKeyPath -Name $regValueName -Value 1
}
}
} else {
Write-Verbose "Failed to find the registry entry for the .NET Runtime version $netVersion"
}
} catch [System.Exception] {
Write-Verbose ("Error while configuring the {0} registry key: {1}" -f $regValueName,$_.Exception.Message)
}
try {
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 + [Net.SecurityProtocolType]::Tls11 + [Net.SecurityProtocolType]::Tls
} catch {
Write-Debug '[Net.ServicePointManager] or [Net.SecurityProtocolType] not found in current environment'
Write-Verbose '[Net.ServicePointManager] or [Net.SecurityProtocolType] not found in current environment'
}
}
end {
Expand Down
2 changes: 1 addition & 1 deletion PhpManager/public/Install-Composer.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
$installer = [System.IO.Path]::GetTempFileName();
Set-NetSecurityProtocolType
Write-Verbose "Downloading from $installerUrl"
Invoke-WebRequest -UseBasicParsing $installerUrl -OutFile $installer
Invoke-WebRequest -UseBasicParsing -Uri $installerUrl -OutFile $installer
} else {
$installer = Get-FileFromUrlOrCache -Url $installerUrl -CachedFileName 'composer-installer.php'
}
Expand Down

0 comments on commit 4710f24

Please sign in to comment.