I have flask web app running on Apache using mod_wsgi. Web app is on a virtualhost using this config:
LoadFile "C:\Program Files (x86)\Python39-32\python39.dll"
LoadModule wsgi_module "C:/wearable/env/Lib/site-packages/mod_wsgi/server/mod_wsgi.cp39-win32.pyd"
WSGIPythonHome "C:/wearable/env"
WSGIApplicationGroup %{GLOBAL}
Listen
0.0.0.0:443 <VirtualHost _default_:443>
SSLEngine on
SSLCertificateFile "${SRVROOT}/conf/new_cert/ServerCertificate.crt" SSLCertificateKeyFile "${SRVROOT}/conf/new_cert/my_cert.key"
SSLCertificateChainFile "${SRVROOT}/conf/new_cert/ChainBundle1.crt"
<Directory C:/wearable/>
Require all granted
</Directory>
WSGIScriptAlias / C:/wearable/start.wsgi
</VirtualHost>
mod_wsgi/Apache is serving the web app on 443. Certificate looks good.
The problem occurs when using a function that make HTTPS call to another server. I get SSL error.
I'm able to manually run those same functions from the python virtual environment and everything works perfect. Seems like mod_wsgi isn't able to access SSL module.
Any ideas on how I can alleviate this issue? Thanks, Ryan
See following stack trace:
[Wed Oct 12 22:32:45.522680 2022] [wsgi:error] [pid 58060:tid 1952] [client
10.252.57.4:53547] Traceback (most recent call last):\r,
[Wed Oct 12 22:32:45.522680 2022] [wsgi:error] [pid 58060:tid 1952] [client
10.252.57.4:53547] File "C:\\wearable\\__init__.py", line 92, in <module>\r,
[Wed Oct 12 22:32:45.522680 2022] [wsgi:error] [pid 58060:tid 1952] [client
10.252.57.4:53547] cc = CariumConnector(test_mode=read_bool(conf['TEST_MODE']), logger=logger, rbe=rbe, db=db)\r,
[Wed Oct 12 22:32:45.522680 2022] [wsgi:error] [pid 58060:tid 1952] [client
10.252.57.4:53547] File "C:\\wearable\\CariumConnector.py", line 58, in __init__\r,
[Wed Oct 12 22:32:45.522680 2022] [wsgi:error] [pid 58060:tid 1952] [client
10.252.57.4:53547] self.kwargs = self.__login()\r,
[Wed Oct 12 22:32:45.522680 2022] [wsgi:error] [pid 58060:tid 1952] [client
10.252.57.4:53547] File "C:\\wearable\\CariumConnector.py", line 386, in __login\r,
[Wed Oct 12 22:32:45.522680 2022] [wsgi:error] [pid 58060:tid 1952] [client
10.252.57.4:53547] result =
requests.post(f"{self.API_HOST}/identity/v1/login/", data={'username': self.__carium_user,'password': self.__carium_pass})\r,
[Wed Oct 12 22:32:45.523679 2022] [wsgi:error] [pid 58060:tid 1952] [client
10.252.57.4:53547] File "C:\\wearable\\env\\Lib\\site-packages\\requests\\api.py", line 115, in post\r,
[Wed Oct 12 22:32:45.523679 2022] [wsgi:error] [pid 58060:tid 1952] [client
10.252.57.4:53547] return request("post", url, data=data, json=json, **kwargs)\r,
[Wed Oct 12 22:32:45.523679 2022] [wsgi:error] [pid 58060:tid 1952] [client
10.252.57.4:53547] File "C:\\wearable\\env\\Lib\\site-packages\\requests\\api.py", line 59, in request\r,
[Wed Oct 12 22:32:45.523679 2022] [wsgi:error] [pid 58060:tid 1952] [client
10.252.57.4:53547] return session.request(method=method, url=url, **kwargs)\r,
[Wed Oct 12 22:32:45.523679 2022] [wsgi:error] [pid 58060:tid 1952] [client
10.252.57.4:53547] File "C:\\wearable\\env\\Lib\\site-packages\\requests\\sessions.py", line 587, in request\r,
[Wed Oct 12 22:32:45.523679 2022] [wsgi:error] [pid 58060:tid 1952] [client
10.252.57.4:53547] resp = self.send(prep, **send_kwargs)\r,
[Wed Oct 12 22:32:45.523679 2022] [wsgi:error] [pid 58060:tid 1952] [client
10.252.57.4:53547] File "C:\\wearable\\env\\Lib\\site-packages\\requests\\sessions.py", line 701, in send\r,
[Wed Oct 12 22:32:45.523679 2022] [wsgi:error] [pid 58060:tid 1952] [client
10.252.57.4:53547] r = adapter.send(request, **kwargs)\r,
[Wed Oct 12 22:32:45.523679 2022] [wsgi:error] [pid 58060:tid 1952] [client
10.252.57.4:53547] File "C:\\wearable\\env\\Lib\\site-packages\\requests\\adapters.py", line 563, in send\r,
[Wed Oct 12 22:32:45.523679 2022] [wsgi:error] [pid 58060:tid 1952] [client
10.252.57.4:53547] raise SSLError(e, request=request)\r,
[Wed Oct 12 22:32:45.523679 2022] [wsgi:error] [pid 58060:tid 1952] [client
10.252.57.4:53547] requests.exceptions.SSLError: HTTPSConnectionPool(host='
api.carium.com', port=443): Max retries exceeded with url: /identity/v1/login/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available."))\r,