I've created a web application using Django 3.2.3 and Python 3.6.8. The application runs without errors in my developer environment on Windows 10 and, on the Windows Server 2019. The problem starts when I try to integrate my app with IIS for production, I get two different errors.
The first error happens when I initially submit the form and the second after I click the browsers back button and re-submit the form again:
The first error is:
[WinError 5] Access is denied: 'C:\\windows\\system32\\config\\systemprofile\\AppData\\Local\\.certifi'
If I click the browser back button and re-submit the form, I then get this error:
Error occurred: Traceback (most recent call last):File "C:\Tools\VirtualEnvironments\podbv2\Lib\site-packages\wfastcgi.py", line 849, in mainfor part in result:File ".\PODBWeb\PODBInterfaces\pod.py", line 19, in searchSPs.get_file("Monthly Reports/", "Inventory Report.xlsx", output_location='c:/!test/')File ".\POD\PODInterfaces\sharepoint.py", line 134, in get_filer = self.retry_loop(self.session.get(rest_call))File "C:\Tools\VirtualEnvironments\pod\lib\site-packages\requests\sessions.py", line 555, in getreturn self.request('GET', url, **kwargs)File "C:\Tools\VirtualEnvironments\pod\lib\site-packages\requests\sessions.py", line 542, in requestresp = self.send(prep, **send_kwargs)File "C:\Tools\VirtualEnvironments\pod\lib\site-packages\requests\sessions.py", line 655, in sendr = adapter.send(request, **kwargs)File "C:\Tools\VirtualEnvironments\pod\lib\site-packages\requests\adapters.py", line 416, in sendself.cert_verify(conn, request.url, verify, cert)File "C:\Tools\VirtualEnvironments\pod\lib\site-packages\requests\adapters.py", line 228, in cert_verify"invalid path: {}".format(cert_loc)) OSError: Could not find a suitable TLS CA certificate bundle, invalid path: C:\windows\system32\config\systemprofile\AppData\Local\.certifi\cacert.pem StdOut: StdErr:
I could be wrong but something about the IIS configuration is preventing python from reading the Windows certificate store which is why its complaining about not being able to find a certificate bundle. My app reads the windows certificate store natively as I have the "python-certifi-win32" library installed so my app shouldn't be trying to find a certificate bundle on the file system.
Can anyone help me understand why this might be happening please and how I can fix the issue without having to deploy a certificate bundle i.e. how can I get my app working "as is". It works without IIS but of course, all the docs suggest I shouldn't really deploy my Django app into a production environment without a proper web server fronting it.
Please respect the fact that the business prefers I use IIS and Windows for support purposes.
Thank you in advance for help.