How to add SSL support to Python?
Solution 1:
Python3 in Ubuntu has SSL support. You can simply test by running python3
and then firing of a couple of commands:
import urllib.request
urllib.request.urlopen('https://askubuntu.com').read()
A ton of HTML will fall out the other side. SSL is working.
As a more general answer to your SO question, I'd strongly consider looking at the requests library. It can be installed with the python3-requests
package and makes all the stuff you're doing much easier and more logical. Boils your entire thing down to:
import requests
requests.post(
url,
auth=requests.auth.HTTPBasicAuth('user', 'pass'),
data={"Hello": "There"},
headers={'content-type': 'application/x-www-form-urlencoded'}
)
I agree that it's largely preference (you can do everything you want without it) but it makes for easier to understand code.