From d0bc054b30deb29e0ab6d43be5c523bdd3bd4461 Mon Sep 17 00:00:00 2001 From: Etienne Monier Date: Tue, 8 Mar 2022 11:27:06 +0100 Subject: [PATCH] feat: Add an option to disable SSL certificate check In case of particular self-signed SSL certificate, the requests verification can fail. To avoid that, an option was added to use the requests verify option. --- gitea/gitea.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/gitea/gitea.py b/gitea/gitea.py index 47160d0..fef7519 100644 --- a/gitea/gitea.py +++ b/gitea/gitea.py @@ -1,9 +1,10 @@ -import json import logging +import json from typing import List, Dict, Union -import requests from frozendict import frozendict +import requests +import urllib3 from .apiobject import User, Organization, Repository, Team from .exceptions import NotFoundException, ConflictException, AlreadyExistsException @@ -24,6 +25,7 @@ class Gitea: gitea_url: str, token_text=None, auth=None, + verify=True, log_level="INFO" ): """ Initializing Gitea-instance.""" @@ -43,6 +45,12 @@ class Gitea: if auth: self.requests.auth = tuple(auth.split(":")) + # Manage SSL certification verification + self.requests.verify = verify + if not verify: + urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) + + def __get_url(self, endpoint): url = self.url + "/api/v1" + endpoint self.logger.debug("Url: %s" % url)