{"record":{"id":"f267224dfe52588c","repo":"TechnitiumSoftware/DnsServer","slug":"web-service-tls-certificate-path-length-cannot-exc","errorCode":null,"errorMessage":"Web service TLS certificate path length cannot exceed 255 characters.","messagePattern":"Web service TLS certificate path length cannot exceed 255 characters\\.","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"DnsServerCore/DnsWebService.cs","lineNumber":2749,"sourceCode":"        }\n\n        private void RemoveWebServiceTlsCertificate()\n        {\n            _webServiceSslServerAuthenticationOptions = null;\n\n            _webServiceTlsCertificatePath = null;\n            _webServiceTlsCertificatePassword = null;\n\n            StopTlsCertificateUpdateTimer();\n        }\n\n        public void SetWebServiceTlsCertificate(string webServiceTlsCertificatePath, string webServiceTlsCertificatePassword)\n        {\n            if (string.IsNullOrWhiteSpace(webServiceTlsCertificatePath))\n                throw new ArgumentException(\"Web service TLS certificate path cannot be null or empty.\", nameof(webServiceTlsCertificatePath));\n\n            if (webServiceTlsCertificatePath.Length > 255)\n                throw new ArgumentException(\"Web service TLS certificate path length cannot exceed 255 characters.\", nameof(webServiceTlsCertificatePath));\n\n            if (webServiceTlsCertificatePassword?.Length > 255)\n                throw new ArgumentException(\"Web service TLS certificate password length cannot exceed 255 characters.\", nameof(webServiceTlsCertificatePassword));\n\n            webServiceTlsCertificatePath = ConvertToAbsolutePath(webServiceTlsCertificatePath);\n\n            LoadWebServiceTlsCertificate(webServiceTlsCertificatePath, webServiceTlsCertificatePassword);\n\n            _webServiceTlsCertificatePath = ConvertToRelativePath(webServiceTlsCertificatePath);\n            _webServiceTlsCertificatePassword = webServiceTlsCertificatePassword;\n\n            StartTlsCertificateUpdateTimer();\n        }\n\n        private void CheckAndLoadSelfSignedCertificate(bool forceGenerateNew, bool throwException)\n        {\n            string selfSignedCertificateFilePath = Path.Combine(_configFolder, \"self-signed-cert.pfx\");\n","sourceCodeStart":2731,"sourceCodeEnd":2767,"githubUrl":"https://github.com/TechnitiumSoftware/DnsServer/blob/d0484b6c1e7439cdc53d67d81e9c876cda2ad756/DnsServerCore/DnsWebService.cs#L2731-L2767","documentation":"ArgumentException thrown by SetWebServiceTlsCertificate when webServiceTlsCertificatePath.Length exceeds 255 characters. The limit exists because the path is later persisted into the binary config (single-byte length prefix) and stored relative; longer paths would corrupt the config layout.","triggerScenarios":"Calling SetWebServiceTlsCertificate with a path longer than 255 characters, e.g. a deeply nested absolute path or a long container/mount path.","commonSituations":"Windows long paths; deep container overlay paths; certificate stored far down a directory tree; very long volume mount prefixes.","solutions":["Move the certificate file closer to the root / config folder so the (relative) path stays under 255 chars.","Use a shorter directory name or reorganize the cert store layout.","On Windows, enable long paths and/or shorten the working directory the relative path is computed from."],"exampleFix":"null","handlingStrategy":"validation","validationCode":"if (webServiceTlsCertificatePath.Length > 255)\n    throw new ArgumentException(\"TLS certificate path must be <= 255 characters.\");","typeGuard":"static bool PathLengthIsValid(string path) => (path?.Length ?? 0) <= 255;","tryCatchPattern":"null","preventionTips":["Keep certificate paths short and close to the config root.","Avoid deeply nested or container overlay paths for certificates.","Use relative paths from the service working directory where possible."],"tags":["dns-server","technitium","tls","certificate","input-validation","configuration","csharp"],"backgroundTag":null,"analyzedSha":"d0484b6c1e7439cdc53d67d81e9c876cda2ad756","analyzedAt":"2026-08-13T22:57:35.508Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}