http.client.HTTPSConnection() causes OPENSSL: FATAL error

image

Python macros code rises fatal error:

import uno

def test_https_connection():
    """Creates a new writer document and do GET request to "www.python.org"."""
    ctx = uno.getComponentContext()
    smgr = ctx.ServiceManager
    desktop = smgr.createInstanceWithContext("com.sun.star.frame.Desktop", ctx)

    # open a writer document
    doc = desktop.loadComponentFromURL(
        "private:factory/swriter", "_blank", 0, ())

    from http.client import HTTPSConnection
    host = "www.python.org"
# OpenSSL: FATAL OPENSSL_Uplink(00007FFBD7B61D50,08): no OPENSSL_Applink
    conn = HTTPSConnection(host) 
    conn.request("GET", "/")
    r1 = conn.getresponse()

    text = doc.Text
    cursor = text.createTextCursor()
    text.insertString(cursor, f"{host}:{r1.status}:{r1.reason}\n", 0)
g_exportedScripts = test_https_connection,

Version: 7.4.5.1 (x64) / LibreOffice Community
Build ID: 9c0871452b3918c1019dde9bfac75448afc4b57f
CPU threads: 8; OS: Windows 10.0 Build 19045; UI render: Skia/Raster; VCL: win
Locale: ru-RU (ru_RU); UI: en-US
Calc: CL

HTTPSConnection(“www.python.org”) works fine in another interpreter.

After launch debug on vscode with

“justMyCode”: false

in launch.json:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python: Current File",
            "type": "python",
            "request": "launch",
            "program": "${file}",
            "console": "integratedTerminal",
            "justMyCode": false
        }
    ]
}

I found a forgotten OS environment variable ‘SSLKEYLOGFILE’

# OpenSSL 1.1.1 keylog file
    if hasattr(context, 'keylog_filename'):
        keylogfile = os.environ.get('SSLKEYLOGFILE')
        if keylogfile and not sys.flags.ignore_environment:
            # next line of code causes OPENSSL: FATAL error
            context.keylog_filename = keylogfile

Why it cause FATAL error only in libreoffice script I still dont know.