{"record":{"id":"742571b37098cea9","repo":"tauri-apps/tauri","slug":"failed-to-parse-tauri-dev-root-certificate","errorCode":null,"errorMessage":"failed to parse TAURI_DEV_ROOT_CERTIFICATE","messagePattern":"failed to parse TAURI_DEV_ROOT_CERTIFICATE","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tauri/src/protocol/tauri.rs","lineNumber":59,"sourceCode":"    let mut client_builder = reqwest::ClientBuilder::new();\n    if use_https {\n      #[cfg(feature = \"rustls-tls\")]\n      if rustls::crypto::CryptoProvider::get_default().is_none() {\n        let _ = rustls::crypto::ring::default_provider().install_default();\n      }\n\n      // we can't load env vars at runtime, gotta embed them in the lib\n      #[allow(unused_variables)]\n      if let Some(cert_pem) = option_env!(\"TAURI_DEV_ROOT_CERTIFICATE\") {\n        #[cfg(any(\n          feature = \"native-tls\",\n          feature = \"native-tls-vendored\",\n          feature = \"rustls-tls\"\n        ))]\n        {\n          log::info!(\"adding dev server root certificate\");\n          let certificate = reqwest::Certificate::from_pem(cert_pem.as_bytes())\n            .expect(\"failed to parse TAURI_DEV_ROOT_CERTIFICATE\");\n          client_builder = client_builder.tls_certs_merge([certificate]);\n        }\n\n        #[cfg(not(any(\n          feature = \"native-tls\",\n          feature = \"native-tls-vendored\",\n          feature = \"rustls-tls\"\n        )))]\n        {\n          log::warn!(\n            \"the dev root-certificate-path option was provided, but you must enable one of the following Tauri features in Cargo.toml: native-tls, native-tls-vendored, rustls-tls\"\n          );\n        }\n      } else {\n        log::warn!(\n          \"loading HTTPS URL; you might need to provide a certificate via the `dev --root-certificate-path` option. You must enable one of the following Tauri features in Cargo.toml: native-tls, native-tls-vendored, rustls-tls\"\n        );\n      }","sourceCodeStart":41,"sourceCodeEnd":77,"githubUrl":"https://github.com/tauri-apps/tauri/blob/460ec35447493200d64290dd7f015d5a91d0fd58/crates/tauri/src/protocol/tauri.rs#L41-L77","documentation":"In dev mode, Tauri loads the root certificate from the `TAURI_DEV_ROOT_CERTIFICATE` environment variable to trust the dev server's TLS. If `reqwest::Certificate::from_pem` cannot parse the PEM data, this panic fires.","triggerScenarios":"Running `tauri dev` with `TAURI_DEV_ROOT_CERTIFICATE` set to a file whose contents are not a valid PEM certificate — wrong file, DER format, empty file, or concatenated/garbage content.","commonSituations":"Developers pointing the env var at a `.crt` in DER form, at a private key instead of a certificate, or forgetting to regenerate the cert after switching dev-server TLS tooling (e.g. mkcert).","solutions":["Regenerate a valid PEM certificate (e.g. with mkcert) and point `TAURI_DEV_ROOT_CERTIFICATE` at the `---BEGIN CERTIFICATE---` PEM file.","Verify the file contents start with `-----BEGIN CERTIFICATE-----` and are not a DER/key file.","Unset `TAURI_DEV_ROOT_CERTIFICATE` if you are not using HTTPS for the dev server.","Check that the path is readable and the file is not truncated or containing multiple unrelated blocks."],"exampleFix":"// before\nTAURI_DEV_ROOT_CERTIFICATE=./devcert.der\n// after\nmkcert -install && TAURI_DEV_ROOT_CERTIFICATE=./rootCA.pem npm run tauri dev","handlingStrategy":"validation","validationCode":"# Verify PEM before pointing the env var at it\ngrep -q '-----BEGIN CERTIFICATE-----' \"$TAURI_DEV_ROOT_CERTIFICATE\" && echo ok || echo 'not a PEM certificate'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use mkcert or openssl to produce a PEM (not DER) root certificate","Check the env var is unset unless dev server uses HTTPS","Regenerate certs after changing dev-server TLS tooling"],"tags":["tls","certificate","env-var","dev-server","panic"],"backgroundTag":"invalid-env-var-value","analyzedSha":"460ec35447493200d64290dd7f015d5a91d0fd58","analyzedAt":"2026-09-18T23:55:51.277Z","contentChangedAt":"2026-09-18T23:55:51.277Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}