16

In the official doc of HTTP PROTOCOL CLIENT

class http.client.HTTPSConnection(host, port=None, key_file=None, cert_file=None, [timeout, ]source_address=None, *, context=None, check_hostname=None)

A subclass of HTTPConnection that uses SSL for communication with secure servers. Default port is 443. If context is specified, it must be a ssl.SSLContext instance describing the various SSL options.

Is there any option to disable ssl verification like python requests library as verify=fasle

For some reasons I can't use HTTPConnection class which would be a straight forward solution. I have to use HTTPSConnection and work with

HTTPConnection.putrequest()

to send request without the ssl verification.

1 Answer 1

45

while creating https connection make sure that you pass context parameter as follows

import http.client
import ssl

conn = http.client.HTTPSConnection(
    HOSTNAME,
    context = ssl._create_unverified_context()
)
Sign up to request clarification or add additional context in comments.

1 Comment

The same is for urllib.request.urlopen(HOSTNAME, context = ssl._create_unverified_context()) since urllib in Python 3.4.3 (docs.python.org/3.7/library/…)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.