{"record":{"id":"b23ec24e04ddf21b","repo":"denoland/deno","slug":"no-private-key-found-in-otel-exporter-otlp-client","errorCode":null,"errorMessage":"no private key found in OTEL_EXPORTER_OTLP_CLIENT_KEY file","messagePattern":"no private key found in OTEL_EXPORTER_OTLP_CLIENT_KEY file","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"ext/telemetry/lib.rs","lineNumber":841,"sourceCode":"        }\n      } else {\n        let ca_certs = match std::env::var(\"OTEL_EXPORTER_OTLP_CERTIFICATE\") {\n          Ok(path) => vec![sys.fs_read(path)?.into_owned()],\n          _ => vec![],\n        };\n\n        let keys = match (\n          std::env::var(\"OTEL_EXPORTER_OTLP_CLIENT_KEY\"),\n          std::env::var(\"OTEL_EXPORTER_OTLP_CLIENT_CERTIFICATE\"),\n        ) {\n          (Ok(key_path), Ok(cert_path)) => {\n            let key = sys.fs_read(key_path)?;\n            let cert = sys.fs_read(cert_path)?;\n\n            let certs = load_certs(&mut std::io::Cursor::new(cert))?;\n            let key =\n              load_private_keys(&key)?.into_iter().next().ok_or_else(|| {\n                deno_core::anyhow::anyhow!(\n                  \"no private key found in OTEL_EXPORTER_OTLP_CLIENT_KEY file\"\n                )\n              })?;\n\n            TlsKeys::Static(TlsKey(certs, key))\n          }\n          _ => TlsKeys::Null,\n        };\n\n        let tls_config =\n          create_client_config(deno_tls::TlsClientConfigOptions {\n            root_cert_store: None,\n            ca_certs,\n            unsafely_ignore_certificate_errors: None,\n            unsafely_disable_hostname_verification: false,\n            cert_chain_and_key: keys,\n            socket_use: SocketUse::Http,\n          })?;","sourceCodeStart":823,"sourceCodeEnd":859,"githubUrl":"https://github.com/denoland/deno/blob/9ad36f7a2cce60488e6ec52283efb32efddaf93a/ext/telemetry/lib.rs#L823-L859","documentation":"For OpenTelemetry OTLP export with client-certificate mTLS, Deno reads the key file named by OTEL_EXPORTER_OTLP_CLIENT_KEY (when OTEL_EXPORTER_OTLP_CLIENT_CERTIFICATE is also set) and runs it through the rustls PEM private-key parser (ext/telemetry/lib.rs:841-846). If the file contains no recognizable `-----BEGIN ... PRIVATE KEY-----` block, the exporter setup fails with this error before any telemetry is sent.","triggerScenarios":"OTEL_EXPORTER_OTLP_CLIENT_KEY pointing at the certificate instead of the key, a CSR, an empty or truncated file, a DER (binary) key, or an encrypted PEM the parser cannot read; values swapped with OTEL_EXPORTER_OTLP_CLIENT_CERTIFICATE.","commonSituations":"Copy-paste of cert/key paths in container env config; keys generated in DER format by an internal CA; secret-injection sidecars writing the file late or partially; k8s secret mounts mixing up key/cert keys.","solutions":["Point OTEL_EXPORTER_OTLP_CLIENT_KEY at a PEM private key (PKCS#8/RSA/EC/SEC1 — a `-----BEGIN ... PRIVATE KEY-----` block) and keep the certificate in OTEL_EXPORTER_OTLP_CLIENT_CERTIFICATE.","Verify the file parses: `openssl pkey -in <keyfile> -noout` (exit 0 means a readable key).","Convert a DER key if needed: `openssl pkey -in key.der -inform DER -out key.pem`.","Confirm the mounted secret is complete (non-empty, fully written) before the process starts."],"exampleFix":"# before\nexport OTEL_EXPORTER_OTLP_CLIENT_CERTIFICATE=/certs/client.pem\nexport OTEL_EXPORTER_OTLP_CLIENT_KEY=/certs/client.pem   # same file — no key block\n# error: no private key found in OTEL_EXPORTER_OTLP_CLIENT_KEY file\n\n# after\nopenssl pkey -in /certs/client.key -noout && echo key ok\nexport OTEL_EXPORTER_OTLP_CLIENT_CERTIFICATE=/certs/client.pem\nexport OTEL_EXPORTER_OTLP_CLIENT_KEY=/certs/client.key","handlingStrategy":"validation","validationCode":"# Verify the PEM key is readable and actually a key before exporting\nopenssl pkey -in \"$OTEL_EXPORTER_OTLP_CLIENT_KEY\" -noout \\\n  || { echo 'CLIENT_KEY file is not a readable PEM private key'; exit 1; }\nopenssl x509 -in \"$OTEL_EXPORTER_OTLP_CLIENT_CERTIFICATE\" -noout \\\n  || { echo 'CLIENT_CERTIFICATE file is not a certificate'; exit 1; }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Name and mount key vs cert files distinctly so the two env vars cannot be swapped.","Convert DER keys to PEM at provisioning time (openssl pkey -inform DER).","Ensure secret sidecars finish writing the key file before the Deno process starts."],"tags":["otel","telemetry","mtls","tls","env"],"backgroundTag":"tls-client-key-invalid","analyzedSha":"9ad36f7a2cce60488e6ec52283efb32efddaf93a","analyzedAt":"2026-08-20T13:07:44.778Z","contentChangedAt":"2026-08-20T13:07:44.778Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}