def ssl_server_options():
    """
    ssl options for tornado https server
    these options are defined in each application's default.conf file
    if left empty, use the self generated keys and certificates included
    in this package.
    this function is backward compatible with python version lower than
    2.7.9 where ssl.SSLContext is not available.
    """
    cafile = options.ssl_ca_cert
    keyfile = options.ssl_key
    certfile = options.ssl_cert
    verify_mode = options.ssl_cert_reqs
    try:
        context = ssl.create_default_context(
            purpose=ssl.Purpose.CLIENT_AUTH, cafile=cafile)
        context.load_cert_chain(certfile=certfile, keyfile=keyfile)
        context.verify_mode = verify_mode
        return context
    except AttributeError:
        ssl_options = {
            'ca_certs': cafile,
            'keyfile': keyfile,
            'certfile': certfile,
            'cert_reqs': verify_mode
        }
        return ssl_options
ssl options for tornado https server
    these options are defined in each application's default.conf file
    if left empty, use the self generated keys and certificates included
    in this package.
    this function is backward compatible with python version lower than
    2.7.9 where ssl.SSLContext is not available.