From 9f0326e9a48a09f8a26dad4ec82d3fb0d5dcd74d Mon Sep 17 00:00:00 2001 From: Mateusz Hajder <6783135+mhajder@users.noreply.github.com> Date: Sun, 3 Aug 2025 13:12:58 +0200 Subject: [PATCH] Add support for disable SSL verification for self-signed certificates --- README.md | 4 ++++ server.py | 9 +++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index fd263b9..c50cbc9 100644 --- a/README.md +++ b/README.md @@ -57,6 +57,10 @@ This is a simple read-only [Model Context Protocol](https://modelcontextprotocol > Show me all configuration changes to the core router in the last month ``` +### SSL Verification (Self-Signed Certificates) + +By default, SSL certificate verification is enabled. If your NetBox instance uses a self-signed certificate, you can disable SSL verification by setting the `VERIFY_SSL` environment variable to `FALSE`, `NO`, `0`, or `OFF`: + ## Development Contributions are welcome! Please open an issue or submit a PR. diff --git a/server.py b/server.py index 98e58ee..d3b7536 100644 --- a/server.py +++ b/server.py @@ -279,11 +279,16 @@ def netbox_get_changelogs(filters: dict): # Load NetBox configuration from environment variables netbox_url = os.getenv("NETBOX_URL") netbox_token = os.getenv("NETBOX_TOKEN") - + verify_ssl_env = os.getenv("VERIFY_SSL", "TRUE").strip().upper() + if verify_ssl_env in ("0", "FALSE", "NO", "OFF"): + verify_ssl = False + else: + verify_ssl = True + if not netbox_url or not netbox_token: raise ValueError("NETBOX_URL and NETBOX_TOKEN environment variables must be set") # Initialize NetBox client - netbox = NetBoxRestClient(url=netbox_url, token=netbox_token) + netbox = NetBoxRestClient(url=netbox_url, token=netbox_token, verify_ssl=verify_ssl) mcp.run(transport="stdio")