def get_ssl_context(private_key, certificate):
    """Get ssl context from private key and certificate paths.
    The return value is used when calling Flask.
    i.e. app.run(ssl_context=get_ssl_context(,,,))
    """
    if (
        certificate
        and os.path.isfile(certificate)
        and private_key
        and os.path.isfile(private_key)
    ):
        context = ssl.SSLContext(ssl.PROTOCOL_TLSv1_2)
        context.load_cert_chain(certificate, private_key)
        return context
    return None
Get ssl context from private key and certificate paths.
    The return value is used when calling Flask.
    i.e. app.run(ssl_context=get_ssl_context(,,,))