{"record":{"id":"44bd19825694706d","repo":"TechnitiumSoftware/DnsServer","slug":"web-server-name-tls-certificate-file-does-not","errorCode":null,"errorMessage":"Web server '{_name}' TLS certificate file does not exists: {webServerTlsCertificateFilePath}","messagePattern":"Web server '(.+?)' TLS certificate file does not exists: (.+?)","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"Apps/BlockPageApp/App.cs","lineNumber":469,"sourceCode":"                    _dnsServer.WriteLog(ex);\n                }\n            }\n\n            private async Task StopWebServerAsync()\n            {\n                if (_webServer is not null)\n                {\n                    await _webServer.DisposeAsync();\n                    _webServer = null;\n                }\n            }\n\n            private void LoadWebServiceTlsCertificate(string webServerTlsCertificateFilePath, string? webServerTlsCertificatePassword)\n            {\n                FileInfo fileInfo = new FileInfo(webServerTlsCertificateFilePath);\n\n                if (!fileInfo.Exists)\n                    throw new ArgumentException(\"Web server '\" + _name + \"' TLS certificate file does not exists: \" + webServerTlsCertificateFilePath);\n\n                switch (Path.GetExtension(webServerTlsCertificateFilePath).ToLowerInvariant())\n                {\n                    case \".pfx\":\n                    case \".p12\":\n                        break;\n\n                    default:\n                        throw new ArgumentException(\"Web server '\" + _name + \"' TLS certificate file must be PKCS #12 formatted with .pfx or .p12 extension: \" + webServerTlsCertificateFilePath);\n                }\n\n                X509Certificate2Collection webServerTlsCertificateCollection = X509CertificateLoader.LoadPkcs12CollectionFromFile(webServerTlsCertificateFilePath, webServerTlsCertificatePassword, X509KeyStorageFlags.PersistKeySet);\n                X509Certificate2? serverCertificate = null;\n\n                foreach (X509Certificate2 certificate in webServerTlsCertificateCollection)\n                {\n                    if (certificate.HasPrivateKey)\n                    {","sourceCodeStart":451,"sourceCodeEnd":487,"githubUrl":"https://github.com/TechnitiumSoftware/DnsServer/blob/d0484b6c1e7439cdc53d67d81e9c876cda2ad756/Apps/BlockPageApp/App.cs#L451-L487","documentation":"Thrown by BlockPageApp LoadWebServiceTlsCertificate when the configured 'webServerTlsCertificateFilePath' does not exist on disk (FileInfo.Exists is false). ArgumentException is raised before any certificate parsing, so the web server cannot start TLS.","triggerScenarios":"Calling web server initialization with a TLS certificate path that points to a missing file: wrong path, file deleted, relative path resolved against an unexpected working directory, or the cert was never placed.","commonSituations":"Path typo; cert stored under a different user/home so the service account cannot see it (permissions read as missing); container deployment that forgot to mount the cert volume; moving the config between machines.","solutions":["Verify the path in 'webServerTlsCertificateFilePath' exists and is readable by the DNS server service account.","Use an absolute path to the .pfx/.p12 file to avoid working-directory ambiguity.","In containers, ensure the certificate file is mounted/copied into the image or volume and the path matches."],"exampleFix":"// before (dnsApp.config)\n\"webServerTlsCertificateFilePath\": \"cert.pfx\"\n// after\n\"webServerTlsCertificateFilePath\": \"/etc/technitium/certs/blockpage.pfx\"","handlingStrategy":"validation","validationCode":"if (!File.Exists(webServerTlsCertificateFilePath))\n    throw new FileNotFoundException($\"TLS certificate file not found: {webServerTlsCertificateFilePath}\");\nif (!new FileInfo(webServerTlsCertificateFilePath).Exists)\n    throw new UnauthorizedAccessException($\"TLS certificate file not readable by service account: {webServerTlsCertificateFilePath}\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use absolute paths for the certificate file.","Ensure the service account has read permission on the file.","In containers, mount the cert volume and reference the mounted path."],"tags":["csharp","tls","certificate","config","filesystem","technitium","block-page-app"],"backgroundTag":null,"analyzedSha":"d0484b6c1e7439cdc53d67d81e9c876cda2ad756","analyzedAt":"2026-08-13T22:57:35.508Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}