Provide httpx default context for OS-provided certs (#11505)

Co-authored-by: Pierrick Hymbert <pierrick.hymbert@gmail.com>
This commit is contained in:
Ray Myers
2025-10-27 17:54:20 -05:00
committed by GitHub
parent 818f743dc7
commit 4decd8b3e9
20 changed files with 93 additions and 37 deletions

View File

@@ -14,6 +14,7 @@ from openhands.integrations.service_types import (
ResourceNotFoundError,
User,
)
from openhands.utils.http_session import httpx_verify_option
class BitBucketMixinBase(BaseGitService, HTTPClient):
@@ -83,7 +84,7 @@ class BitBucketMixinBase(BaseGitService, HTTPClient):
"""
try:
async with httpx.AsyncClient() as client:
async with httpx.AsyncClient(verify=httpx_verify_option()) as client:
bitbucket_headers = await self._get_headers()
response = await self.execute_request(
client, url, bitbucket_headers, params, method

View File

@@ -11,6 +11,7 @@ from openhands.integrations.service_types import (
UnknownException,
User,
)
from openhands.utils.http_session import httpx_verify_option
class GitHubMixinBase(BaseGitService, HTTPClient):
@@ -43,7 +44,7 @@ class GitHubMixinBase(BaseGitService, HTTPClient):
method: RequestMethod = RequestMethod.GET,
) -> tuple[Any, dict]: # type: ignore[override]
try:
async with httpx.AsyncClient() as client:
async with httpx.AsyncClient(verify=httpx_verify_option()) as client:
github_headers = await self._get_headers()
# Make initial request
@@ -83,7 +84,7 @@ class GitHubMixinBase(BaseGitService, HTTPClient):
self, query: str, variables: dict[str, Any]
) -> dict[str, Any]:
try:
async with httpx.AsyncClient() as client:
async with httpx.AsyncClient(verify=httpx_verify_option()) as client:
github_headers = await self._get_headers()
response = await client.post(

View File

@@ -10,6 +10,7 @@ from openhands.integrations.service_types import (
UnknownException,
User,
)
from openhands.utils.http_session import httpx_verify_option
class GitLabMixinBase(BaseGitService, HTTPClient):
@@ -41,7 +42,7 @@ class GitLabMixinBase(BaseGitService, HTTPClient):
method: RequestMethod = RequestMethod.GET,
) -> tuple[Any, dict]: # type: ignore[override]
try:
async with httpx.AsyncClient() as client:
async with httpx.AsyncClient(verify=httpx_verify_option()) as client:
gitlab_headers = await self._get_headers()
# Make initial request
@@ -99,7 +100,7 @@ class GitLabMixinBase(BaseGitService, HTTPClient):
if variables is None:
variables = {}
try:
async with httpx.AsyncClient() as client:
async with httpx.AsyncClient(verify=httpx_verify_option()) as client:
gitlab_headers = await self._get_headers()
# Add content type header for GraphQL
gitlab_headers['Content-Type'] = 'application/json'

View File

@@ -36,6 +36,7 @@ from openhands.integrations.service_types import (
)
from openhands.microagent.types import MicroagentContentResponse, MicroagentResponse
from openhands.server.types import AppMode
from openhands.utils.http_session import httpx_verify_option
class ProviderToken(BaseModel):
@@ -174,7 +175,7 @@ class ProviderHandler:
) -> SecretStr | None:
"""Get latest token from service"""
try:
async with httpx.AsyncClient() as client:
async with httpx.AsyncClient(verify=httpx_verify_option()) as client:
resp = await client.get(
self.REFRESH_TOKEN_URL,
headers={