import sys

try:
    import certifi
    import ssl
except ImportError:
    ssl = None

import config

VERIFY = True
SSL_CONTEXT = None

def load_context():
    global VERIFY
    global SSL_CONTEXT
    try:
        if ssl:
            SSL_CONTEXT = ssl.create_default_context(cafile=certifi.where())
            if config.get_settings()['protocol'].get('no_cert_verify'):
                SSL_CONTEXT = ssl._create_unverified_context()
                VERIFY = False
        else:
            SSL_CONTEXT = None
    except:
        SSL_CONTEXT = None

load_context()
