Skip to content

Commit f2e22de

Browse files
committed
Add certifi for urllib ssl context
1 parent c2bcb34 commit f2e22de

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

SharedProcessors/GitLabReleasesInfoProvider.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,11 @@
1616
# limitations under the License.
1717
"""Shared processor to allow recipes to download releases from GitLab instances."""
1818

19+
import certifi
1920
import json
2021
import os
2122
import re
23+
import ssl
2224
from urllib.request import Request, urlopen
2325

2426
from autopkglib import Processor, ProcessorError, get_autopkg_version
@@ -85,6 +87,10 @@ class GitLabReleasesInfoProvider(Processor):
8587
},
8688
}
8789

90+
def ssl_context_certifi(self):
91+
"""Provide ssl context using certifi certificate store."""
92+
return ssl.create_default_context(cafile=certifi.where())
93+
8894
def gitlab_api_get(self, endpoint):
8995
"""Helps to communicate with the GitLab API by setting necessary headers."""
9096
GITLAB_HOSTNAME = self.env.get("GITLAB_HOSTNAME")
@@ -101,7 +107,7 @@ def gitlab_api_get(self, endpoint):
101107
}
102108
url = f"{GITLAB_API_BASE_URL}{endpoint}"
103109
req = Request(url, headers=headers)
104-
with urlopen(req) as response:
110+
with urlopen(req, context=self.ssl_context_certifi()) as response:
105111
data = response.read()
106112
return data
107113

0 commit comments

Comments
 (0)