{"record":{"id":"7d5cc255db980981","repo":"sigoden/dufs","slug":"no-supported-certificate-in-file","errorCode":null,"errorMessage":"No supported certificate in file `{}`","messagePattern":"No supported certificate in file `(.+?)`","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"src/utils.rs","lineNumber":67,"sourceCode":"#[cfg(feature = \"tls\")]\npub fn load_certs<T: AsRef<Path>>(file_name: T) -> Result<Vec<CertificateDer<'static>>> {\n    let mut certs = vec![];\n    for cert in CertificateDer::pem_file_iter(file_name.as_ref()).with_context(|| {\n        format!(\n            \"Failed to load cert file at `{}`\",\n            file_name.as_ref().display()\n        )\n    })? {\n        let cert = cert.with_context(|| {\n            format!(\n                \"Invalid certificate data in file `{}`\",\n                file_name.as_ref().display()\n            )\n        })?;\n        certs.push(cert)\n    }\n    if certs.is_empty() {\n        anyhow::bail!(\n            \"No supported certificate in file `{}`\",\n            file_name.as_ref().display()\n        );\n    }\n    Ok(certs)\n}\n\n// Load private key from file.\n#[cfg(feature = \"tls\")]\npub fn load_private_key<T: AsRef<Path>>(file_name: T) -> Result<PrivateKeyDer<'static>> {\n    PrivateKeyDer::from_pem_file(file_name.as_ref()).with_context(|| {\n        format!(\n            \"Failed to load key file at `{}`\",\n            file_name.as_ref().display()\n        )\n    })\n}\n","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/sigoden/dufs/blob/fe7fd564f80dfbac361c8e0589c3845638149d38/src/utils.rs#L49-L85","documentation":"Raised in load_certs (tls feature) at server startup: the PEM certificate file was readable, but after parsing every PEM block, zero certificates were extracted — meaning the file contains no supported certificate entries (e.g. it holds only a private key, or is empty/garbage). The server cannot build a TLS config without at least one certificate, so startup fails via serve.","triggerScenarios":"Thrown at src/utils.rs:67 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Point --tls-cert at a file that actually contains a PEM certificate (-----BEGIN CERTIFICATE----- blocks)","If the file only holds the private key, supply it via the key option and use a separate certificate file","Regenerate or re-export the certificate in PEM format"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"fe7fd564f80dfbac361c8e0589c3845638149d38","analyzedAt":"2026-09-09T13:01:22.843Z","contentChangedAt":"2026-09-09T13:01:22.843Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}