langfuse icon indicating copy to clipboard operation
langfuse copied to clipboard

bug: SSL Certificate Verification Error with Self-Signed Certificates in OpenTelemetry Export

Open nags-coder opened this issue 1 year ago • 10 comments

Describe the bug

Summary: Langfuse fails to export telemetry data when connecting to instances using self-signed certificates, despite configuring SSL verification to be disabled for the main Langfuse client.

Environment:

  • OS: macOS
  • Python: 3.10.18
  • Langfuse SDK: 3.1.0
  • Host: Custom enterprise deployment with self-signed certificates

Issue Details: While the main Langfuse authentication works correctly with SSL verification disabled (httpx_client=httpx.Client(verify=False) and ssl._create_default_https_context = ssl._create_unverified_context), the OpenTelemetry trace exporter fails with SSL certificate verification errors when attempting to export spans to /api/public/otel/v1/traces.

Error Message:

ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self-signed certificate in certificate chain (_ssl.c:1017)

Expected Behavior: When SSL verification is disabled for the Langfuse client, all internal HTTP clients (including OpenTelemetry exporters) should respect this configuration and not perform SSL certificate verification.

Actual Behavior: The OpenTelemetry exporter creates its own requests session internally that doesn't inherit the SSL configuration from the main Langfuse client, causing SSL verification failures.

Workaround: Setting os.environ['OTEL_SDK_DISABLED'] = 'true' resolves the issue but disables telemetry export entirely.

Suggested Fix: The Langfuse SDK should propagate SSL configuration settings to all internal HTTP clients, including OpenTelemetry exporters, when SSL verification is disabled.

This bug affects enterprise deployments using self-signed certificates and prevents proper telemetry collection in those environments.

To reproduce

import time
import httpx
from langfuse import Langfuse, observe
import logging
import ssl
# from byaisdk_tracing import logger, ByTracing, by_monitor

# Disable SSL verification globally for self-signed certificates
ssl._create_default_https_context = ssl._create_unverified_context

client = httpx.Client(verify=False)

langfuse = Langfuse(
    secret_key="sk-******",
    public_key="pk-*********",
    httpx_client=client,
    host="https://*******"
)

# Optional: Verify the configuration
langfuse.auth_check()
print('Auth is fine')

def wait():
    time.sleep(1)

@observe
def capitalize(input: str):
    return input.upper()
 
def main_fn(query: str):
    wait()
    capitalized = capitalize(query)
    return f"Q:{capitalized}; A: nice too meet you!"
 
main_fn("hi there")

SDK and container versions

No response

Additional information

No response

Are you interested to contribute a fix for this bug?

No

nags-coder avatar Jul 03 '25 07:07 nags-coder

Hi @nags-coder! I'm Dosu and I’m helping the langfuse team.

This is a known limitation: the Langfuse Python SDK does not propagate SSL verification settings (like verify=False) from the main client to the OpenTelemetry exporter, so the exporter creates its own HTTP session and fails with SSL errors when using self-signed certificates. There is currently no supported or documented way to disable SSL verification or pass a custom CA for the OpenTelemetry exporter in the SDK. Setting environment variables like OTEL_EXPORTER_OTLP_INSECURE=true does not work for the Python exporter, and the only reliable workaround is to disable OpenTelemetry entirely with OTEL_SDK_DISABLED=true, which also disables all telemetry export—usually not desirable discussion.

Some users have worked around this by adding their self-signed CA to the trusted store on the host/container or by setting REQUESTS_CA_BUNDLE to point to a custom CA bundle, but this isn't always feasible issue. The main Langfuse repo only contains backend/server code, so any fix would need to be made in the Python SDK.

If you need to track progress or see related discussions, check out these threads:

Right now, there is no built-in way to disable SSL verification for OpenTelemetry exports in the Langfuse Python SDK.

To reply, just mention @dosu.


Docs are dead. Just use Dosu.

Leave Feedback Ask Dosu about langfuse Share Dosu with your team

dosubot[bot] avatar Jul 03 '25 07:07 dosubot[bot]

@nags-coder, thanks for raising this! Could you please try setting OTEL_EXPORTER_OTLP_TRACES_INSECURE=True as well in your environment running the Python SDK?

hassiebp avatar Jul 07 '25 08:07 hassiebp

@hassiebp with client = httpx.Client(verify=False) langfuse is generating the logs. This is tested on version 3.1.3.

nags-coder avatar Jul 14 '25 10:07 nags-coder

@nags-coder, thanks for raising this! Could you please try setting OTEL_EXPORTER_OTLP_TRACES_INSECURE=True as well in your environment running the Python SDK?

This unfortunately does not seem to work for me

For other people having the same issue

Langfuse(
  httpx_client=httpx.AsyncClient(verify=False),
)

tonxxd avatar Aug 12 '25 09:08 tonxxd

Please check our updated docs on this: https://langfuse.com/docs/observability/sdk/python/sdk-v3#self-signed-ssl-certificates-self-hosted-langfuse

I can't find where it has this header

ronald0samuel avatar Sep 01 '25 20:09 ronald0samuel

@ronald0samuel here's the link that works for me (searched their website to find it): https://langfuse.com/docs/observability/sdk/python/advanced-usage#self-signed-ssl-certificates-self-hosted-langfuse

EDIT: Works as in the page isn't a 404. The solution still doesn't seem to work.

bostrt avatar Sep 08 '25 19:09 bostrt

@ronald0samuel the link you provide is not relevant. httpx.Client(verify=False) is not working, and the link doesn't provide a answer how to make langfuse client 3.0 to work with self signed server

(tested on >3 and >2 server)

IvanAntipovAtExness avatar Nov 27 '25 20:11 IvanAntipovAtExness

Hi @nags-coder! I'm Dosu and I’m helping the langfuse team.

This is a known limitation: the Langfuse Python SDK does not propagate SSL verification settings (like verify=False) from the main client to the OpenTelemetry exporter, so the exporter creates its own HTTP session and fails with SSL errors when using self-signed certificates. There is currently no supported or documented way to disable SSL verification or pass a custom CA for the OpenTelemetry exporter in the SDK. Setting environment variables like OTEL_EXPORTER_OTLP_INSECURE=true does not work for the Python exporter, and the only reliable workaround is to disable OpenTelemetry entirely with OTEL_SDK_DISABLED=true, which also disables all telemetry export—usually not desirable discussion.

Some users have worked around this by adding their self-signed CA to the trusted store on the host/container or by setting REQUESTS_CA_BUNDLE to point to a custom CA bundle, but this isn't always feasible issue. The main Langfuse repo only contains backend/server code, so any fix would need to be made in the Python SDK.

If you need to track progress or see related discussions, check out these threads:

Right now, there is no built-in way to disable SSL verification for OpenTelemetry exports in the Langfuse Python SDK.

To reply, just mention @dosu.

How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other  Join Discord Share on X

@dosu

Could you help to check if there's any latest native way of disabling SSL verfication for OpenTelemetry?

frankcaoyun avatar Feb 03 '26 09:02 frankcaoyun

There is still no native, built-in way to disable SSL verification for OpenTelemetry exports in the Langfuse Python SDK. This is a known limitation and is tracked as an open feature request in the SDK’s issue tracker (issue #7485). Setting environment variables like OTEL_EXPORTER_OTLP_TRACES_INSECURE=True or OTEL_EXPORTER_OTLP_CERTIFICATE sometimes works for other SDKs, but does not reliably disable SSL verification for the Python OpenTelemetry exporter (discussion).

Current workarounds are: add your self-signed CA to the trusted store or set REQUESTS_CA_BUNDLE to your CA bundle, or (not recommended for production) patch the OTEL exporter’s session in code:

client._otel_tracer.span_processor._span_processors[0].span_exporter._session.verify = False

This is not officially supported and may break with SDK updates (workaround details).

There is an open, not-yet-merged PR to improve OTLP HTTP exporter environment variable support, but nothing is available natively yet. For production, using a certificate from a recognized CA is strongly recommended for security reasons (discussion).

To reply, just mention @dosu.


Docs are dead. Just use Dosu.

Leave Feedback Ask Dosu about langfuse Share Dosu with your team

dosubot[bot] avatar Feb 03 '26 09:02 dosubot[bot]