import ssl


def _ssl_opts(rpc_opts):
    """
    Given a dict of config options returned by _rpc_opts, return a dict of
    options which can be passed to the ssl module.
    """
    ssl_opts = {
        'ca_certs': rpc_opts['ca'],
        'keyfile': rpc_opts['client_key'],
        'certfile': rpc_opts['client_cert'],
        'cert_reqs': ssl.CERT_REQUIRED if rpc_opts['ca'] else None,
        'ssl_version': getattr(ssl, rpc_opts['ssl_version'])
    }
    return {k: v for k, v in ssl_opts.items() if v}