poshbotio / PoshBot.XKCD

PoshBot module for retrieving XKCD comics
MIT License
5 stars 1 forks source link

get-xkcd errors with Could not create SSL/TLS secure channel #3

Closed DunlapOverbelt closed 7 years ago

DunlapOverbelt commented 7 years ago

Current Behavior

Running PoshBot on Windows Server 2016 Standard with POSH version 5.1, an error like below is recorded whenever get-xkcd is run. Invoke-RestMethod http://xkcd.com/info.0.json Invoke-RestMethod : The request was aborted: Could not create SSL/TLS secure channel. At line:1 char:1

Expected Behavior

A secure connection should be establish, however the there seems to be an incompatibility with the default security protocol used by powershell versus the server.

Possible Solution

Putting the following at the top of PoshBot.XKCD.psm1 appears to fix the issue:

Steps to Reproduce (for bugs)

  1. Invoke-RestMethod http://xkcd.com/info.0.json

Context

With out the fix applied above, I could not enjoy the PoshBot.KCD plugin due to lack of comics loading. This post was helpful in understanding the problem and fix: http://blogs.perficient.com/microsoft/2016/04/tsl-1-2-and-net-support/

Your Environment

devblackops commented 7 years ago

Good catch @DunlapOverbelt. Do you want to put in a PR for this and probably change the XKCD URLs to https since they redirect to that anyway?

devblackops commented 7 years ago

Fixed in 9277bfa165f83b8d936f40e67cb24efe1ea7dd4a.