From 0e72e9e0e6521036af008344d16d3d257772ee5a Mon Sep 17 00:00:00 2001 From: "bobo.yang" Date: Wed, 29 May 2024 17:02:51 +0800 Subject: [PATCH] chore: Add SSL context to HTTPS connection in http_openai.py --- devchat/openai/http_openai.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/devchat/openai/http_openai.py b/devchat/openai/http_openai.py index 5c1c7a24..dde07453 100755 --- a/devchat/openai/http_openai.py +++ b/devchat/openai/http_openai.py @@ -1,6 +1,7 @@ import http.client import json import os +import ssl import sys from urllib.parse import urlparse @@ -71,10 +72,12 @@ def stream_request(api_key, api_base, data): if api_base.startswith("https://"): if proxy_setting["host"]: - connection = http.client.HTTPSConnection(**proxy_setting) + connection = http.client.HTTPSConnection( + **proxy_setting, context=ssl._create_unverified_context() + ) connection.set_tunnel(url) else: - connection = http.client.HTTPSConnection(url) + connection = http.client.HTTPSConnection(url, context=ssl._create_unverified_context()) else: if proxy_setting["host"]: connection = http.client.HTTPConnection(**proxy_setting)