RamblingCookieMonster / PSDepend

PowerShell Dependency Handler
MIT License
277 stars 75 forks source link

Support for TLS1.2 #85

Closed raandree closed 6 years ago

raandree commented 6 years ago

PSDepends thrown the following error when using an HTTPS download link:

Exception calling "DownloadFile" with "2" argument(s): "The request was aborted: Could not create SSL/TLS secure channel."
At C:\Users\randr\Documents\WindowsPowerShell\Modules\PSDepend\0.2.0\Private\Get-WebFile.ps1:7 char:5
+     $webclient.DownloadFile($URL, $Path)
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : WebException

The PSDepends configuration used:

@{
    # Set up a mini virtual environment...
    PSDependOptions = @{
        AddToPath = $True
        Target = 'BuildOutput\Modules'
        Parameters = @{
        }
    }

    #...

    #File Download
    'https://github.com/AutomatedLab/AutomatedLab/raw/develop/LabSources/Tools/WinSATAPI.dll' = @{
        DependencyType = 'FileDownload'
        Target = '.\DLLs\WinSATAPI.dll'
    }
}
RamblingCookieMonster commented 6 years ago

Good catch! Mind using [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12? This will add tls12 to current set of options vs. replace - just in case this runs in an interactive session and someone has some niche dependency on another protocol in that list.

Also! I think your's is more concise as is, but if you end up pulling more than a few files, the github type might be worth looking at

Thanks!

RamblingCookieMonster commented 6 years ago

Whee! Alrighty, hope you don't mind the change, merging and deploying now!