fsagbuya This did the trick to fix the import error!
MSYS2 has an added complication in that if your influx server uses a self-signed SSL certificate or in general is on an https address, MSYS2 does not use the Windows certificate store, but instead uses its own store. This means that you have to either 1.) disable SSL verification (I would NOT in general suggest this) or 2.) generate your certificate keys in PowerShell and point aiohttp
to the proper store using a certifi
hack. I'll detail this below.
To generate your certificate file, open PowerShell and run the following script to generate windows.pem
in C:\Users\<USERNAME>
:
get-childitem -path cert:\LocalMachine\Root | ForEach-Object {
$hash = $_.GetCertHashString()
$base64certificate = @"
-----BEGIN CERTIFICATE-----
$([Convert]::ToBase64String($_.export('Cert'), [System.Base64FormattingOptions]::InsertLineBreaks))
-----END CERTIFICATE-----
"@
[System.IO.File]::AppendAllText("$home\windows.pem", $base64certificate)
}
Open this windows.pem
file in your favorite text editor and copy the contents.
In MSYS2 run pacaman -S mingw-w64-clang-x86_64-python-certifi
to install the certifi
package. Then in the MSYS2 console run echo "import certifi; print(certifi.where())" | python
. Find the file that is printed, open it in your favorite text editor and paste the contents of windows.pem
into it.
Now, open ../clang64/python3.11/site-packages/artiq_influx_generic/artiq_influx_generic.py. import
both ssl
and certifi
. define a module level variable of ssl_ctx=ssl.create_default_context(cafile=certifi.where())
.
Finally, in DBWriter._do
and DBReader.send_query
replace the lines async with aiohttp.ClientSession() as session:
with async with aiohttp.ClientSession(connector=aiohttp.TCPConnector(ssl=ssl_ctx)) as session:
.
This will allow you to access your Windows SSL certificate store, which contains your self-signed and other SSL certs, inside MSYS2 and write data to your influx.
I'll send an email about this to the repo's maintainer and I would also welcome any more elegant solution that doesn't require PowerShell and a manual copy/paste.