"'module' object has no attribute 'SSLContext'" error when using flocker-api
<p>This is the flocker api url </p>

<p><a href="https://docs.clusterhq.com/en/latest/reference/api.html" rel="nofollow">https://docs.clusterhq.com/en/latest/reference/api.html</a></p>

<p>I try to use httplib to make https connection,but I can not get through the ssl verification [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:765)</p>

<p>by the way: it shows an error :</p>

<blockquote>
  <p>AttributeError: 'module' object has no attribute 'SSLContext' </p>
</blockquote>

<p>My python version is 2.7.6, <strong>BUT</strong> if I use python 2.7.5 it pass through.</p>

<p>i solved my problem myself,this is my code
    import httplib
    import ssl
    import json
    import socket</p>

<pre><code>httpsConn = None
# KEY_FILE = "/etc/flocker/scio01.key"
# CERT_FILE = "/etc/flocker/scio01.crt"
# CA_FILE = "/etc/flocker/cluster.crt"

KEY_FILE = "/root/lichao_test/scio01.key"
CERT_FILE = "/root/lichao_test/scio01.crt"
CA_FILE = "/root/lichao_test/cluster.crt"

HOST = "192.168.9.14"
PORT = 4523

body = {
    "dataset_id": "a1234567-3fb9-4c1a-81ce-efeeb9f2c788",
    "primary": "c1234567-17b2-4812-beca-1434997d6c3f",
    "metadata": {
        "name": "demo",
        "owner": "lichao"
    },
    "maximum_size": 67108864
}

try:
    httpsConn = httplib.HTTPSConnection(HOST, PORT)
    sock = socket.create_connection((HOST, PORT))
    try:
        httpsConn.sock = ssl.wrap_socket(sock, ca_certs=CA_FILE, keyfile=KEY_FILE, certfile=CERT_FILE,
                                         cert_reqs=ssl.CERT_REQUIRED, ssl_version=ssl.PROTOCOL_SSLv3)
        json_body = json.dumps(body)
        # httpsConn.request(method="POST", url="https://192.168.9.14:4523/v1/configuration/datasets",
        #                   headers={"Content-type": "application/json", 'Connection': 'keep-alive'}, body=json_body)
        httpsConn.request(method="GET",url="/v1/configuration/datasets",headers={"Content-type": "application/json", 'Connection': 'keep-alive'})

        res = httpsConn.getresponse()
        body = res.read()
        status = res.status
        print "-" * 70
        print status, body
    except ssl.SSLError, e:
        print "Trying SSLv23.",e
except Exception, e:
    import traceback

    print traceback.format_exc()
</code></pre>

python ssl