tauri-apps/tauri · error
failed to parse TAURI_DEV_ROOT_CERTIFICATE
Error message
failed to parse TAURI_DEV_ROOT_CERTIFICATE
What it means
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.
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.
Example fix
// before TAURI_DEV_ROOT_CERTIFICATE=./devcert.der // after mkcert -install && TAURI_DEV_ROOT_CERTIFICATE=./rootCA.pem npm run tauri dev
Defensive patterns
Strategy: validation
Validate before calling
# Verify PEM before pointing the env var at it grep -q '-----BEGIN CERTIFICATE-----' "$TAURI_DEV_ROOT_CERTIFICATE" && echo ok || echo 'not a PEM certificate'
Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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).
Understand the failure class
Background: "is not a valid" / "Invalid ... value" environment variable errors: how libraries validate env vars and what to do when they reject yours — this error's family across 48 libraries.
- SSL/TLS and certificate errors — how TLS handshakes and certificate validation fail.
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- beforeDevCommand ` ` failed with exit code
- Can't extract file name from path
- Can't read source directory
- cannot use both `resources` and `resources_map`
- Couldn't bind to on
AI-assisted analysis of tauri-apps/tauri@460ec35447 (2026-09-18).
Data as JSON: /api/errors/742571b37098cea9.
Report an issue: GitHub.
Appendix: source
Thrown at crates/tauri/src/protocol/tauri.rs:59
let mut client_builder = reqwest::ClientBuilder::new();
if use_https {
#[cfg(feature = "rustls-tls")]
if rustls::crypto::CryptoProvider::get_default().is_none() {
let _ = rustls::crypto::ring::default_provider().install_default();
}
// we can't load env vars at runtime, gotta embed them in the lib
#[allow(unused_variables)]
if let Some(cert_pem) = option_env!("TAURI_DEV_ROOT_CERTIFICATE") {
#[cfg(any(
feature = "native-tls",
feature = "native-tls-vendored",
feature = "rustls-tls"
))]
{
log::info!("adding dev server root certificate");
let certificate = reqwest::Certificate::from_pem(cert_pem.as_bytes())
.expect("failed to parse TAURI_DEV_ROOT_CERTIFICATE");
client_builder = client_builder.tls_certs_merge([certificate]);
}
#[cfg(not(any(
feature = "native-tls",
feature = "native-tls-vendored",
feature = "rustls-tls"
)))]
{
log::warn!(
"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"
);
}
} else {
log::warn!(
"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"
);
}View on GitHub (pinned to 460ec35447)