0

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.

Paul
  • 13
  • 3
  • I suggest that you can solve the first error first, you can try to set the enough permission for your IIS application pool identity. open IIS management console -> Find your python application application pool -> Right click the folder which you hosted the application and select property -> Select the Security tab -> Click the Edit button and Add button -> Click the Locations button -> Enter IIS AppPool in the Enter the object names to select: text box -> Click the Check Names button and click OK -> Check Modify under the Allow column, and click OK. – samwu Jul 05 '21 at 07:08
  • Your suggestion made me think about the security and I made a slightly different modification. I right-clicked on the application pool for the app and selected Advanced Settings. I then changed the Identity parameter in the Process Model section and set it to a specific account as a test, this removed all the issues. So, it is a permissions error on the Application Pool as you suggested. When I tried to implement your suggestion, I followed your instructions but I could not find a user or group named 'IIS AppPool' to set permissions for on the app folder. Could you clarify this please? – Paul Jul 05 '21 at 10:20
  • Enter IIS AppPool\ (eg: IIS AppPool\smartcrypt) , you can refer to this link: [https://stackoverflow.com/a/7334485/13336642](https://stackoverflow.com/a/7334485/13336642). – samwu Jul 06 '21 at 09:09

0 Answers0