nager / Nager.PublicSuffix

.NET public suffix domain parser
MIT License
155 stars 22 forks source link

Access to the path '...\publicsuffixcache.dat' is denied in WebTldRuleProvider #59

Closed bkarakaya01 closed 9 months ago

bkarakaya01 commented 1 year ago

When using the DomainParser class with WebTldRuleProvider and default settings, I am encountering the following error Access to the path 'C:\Windows\TEMP\publicsuffixcache.dat' is denied in the real server environment.

This problem can be overcome by the following two methods:

  1. Use a FileTldRuleProvider, so that the file can be saved and used under the root folder of the application.

  2. As "Microsoft's Application Pool Identities Documentation" states, you can find the publicsuffixcache.dat' file, and then you can arrange the permissions by right clicking file and following Properties - Security - Edit - Add - Enter the object names to select (Write Users and Check Names) - OK. So you have to give permissions to Users.

I didn't like choosing the second option because I thought it would create security vulnerabilities (maybe I'm thinking wrong) and it would be hard to manage in case of multiple servers . Likewise, I may not want to work with a local file, thus i may not use FileTldRuleProvider.

In such a situation, I could not find how to overcome this problem. I will be glad if you help me. For now, I have basically solved the problem, but I am writing here to understand the source of the problem. Also, if someone is stuck like me, maybe it will be useful information.

tinohager commented 1 year ago

Hi

I think we can solve this problem quicky, my proposal

use WebTldRuleProvider -> inject a own instance of FileCacheProvider we change the FileCacheProvider with an option to disable var tempPath = Path.GetTempPath(); and allow own path

bkarakaya01 commented 1 year ago

use WebTldRuleProvider -> inject a own instance of FileCacheProvider we change the FileCacheProvider with an option to disable var tempPath = Path.GetTempPath(); and allow own path

Yes, I guess this is a right way of solving the issue. Thank you.