Skip to content

httpx.ConnectError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1002) #1370

@1e9-7

Description

@1e9-7

Description

I am currently using the mcp-python-sdk to set up an MCP client with Streamable HTTP as the transport layer protocol. However, since I'm working in an internal network environment, I encounter the following HTTPS error:

httpx.ConnectError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1002)
the code of me is:

import asyncio
from mcp import ClientSession
from mcp.client.streamable_http import streamablehttp_client

async def main():
    # Connect to a streamable HTTP server
#the url of my mcp server can't avail
    async with streamablehttp_client("https://mcp.higress.ai/mcp-ip-query/cmfdmaly") as (
        read_stream,
        write_stream,
        _,
    ):
        # Create a session using the client streams
        async with ClientSession(read_stream, write_stream) as session:
            # Initialize the connection
            await session.initialize()
            # List available tools
            tools = await session.list_tools()
            print(f"Available tools: {[tool.name for tool in tools.tools]}")


if __name__ == "__main__":
    asyncio.run(main())

To temporarily resolve this issue, I modified /.venv/Lib/site-packages/mcp/shared/_httpx_utils.py by adding "verify": False after line 66.

My request is to support passing a verify parameter when constructing the streamablehttp_client, allowing users to configure certificate verification flexibly without modifying the source code.

References

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    P0Broken core functionality, security issues, critical missing featurebugSomething isn't workingneeds maintainer actionPotentially serious issue - needs proactive fix and maintainer attention

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions