From 7db574b6d63c0118a99778f54b34371066392044 Mon Sep 17 00:00:00 2001 From: Victor M Date: Mon, 3 Jun 2024 10:51:19 +0200 Subject: [PATCH] retrieve CA certificate from URL (#370) --- bonfire/utils.py | 38 ++++++-------------------------------- 1 file changed, 6 insertions(+), 32 deletions(-) diff --git a/bonfire/utils.py b/bonfire/utils.py index c9e3e37c..21f9dcc6 100644 --- a/bonfire/utils.py +++ b/bonfire/utils.py @@ -10,6 +10,8 @@ import subprocess import tempfile import time +from urllib.request import urlretrieve + from distutils.version import StrictVersion from pathlib import Path from urllib.parse import urlparse @@ -63,33 +65,7 @@ def get_config_path(): GIT_SHA_RE = re.compile(r"[a-f0-9]{40}") -GL_CA_CERT = """ ------BEGIN CERTIFICATE----- -MIIENDCCAxygAwIBAgIJANunI0D662cnMA0GCSqGSIb3DQEBCwUAMIGlMQswCQYD -VQQGEwJVUzEXMBUGA1UECAwOTm9ydGggQ2Fyb2xpbmExEDAOBgNVBAcMB1JhbGVp -Z2gxFjAUBgNVBAoMDVJlZCBIYXQsIEluYy4xEzARBgNVBAsMClJlZCBIYXQgSVQx -GzAZBgNVBAMMElJlZCBIYXQgSVQgUm9vdCBDQTEhMB8GCSqGSIb3DQEJARYSaW5m -b3NlY0ByZWRoYXQuY29tMCAXDTE1MDcwNjE3MzgxMVoYDzIwNTUwNjI2MTczODEx -WjCBpTELMAkGA1UEBhMCVVMxFzAVBgNVBAgMDk5vcnRoIENhcm9saW5hMRAwDgYD -VQQHDAdSYWxlaWdoMRYwFAYDVQQKDA1SZWQgSGF0LCBJbmMuMRMwEQYDVQQLDApS -ZWQgSGF0IElUMRswGQYDVQQDDBJSZWQgSGF0IElUIFJvb3QgQ0ExITAfBgkqhkiG -9w0BCQEWEmluZm9zZWNAcmVkaGF0LmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEP -ADCCAQoCggEBALQt9OJQh6GC5LT1g80qNh0u50BQ4sZ/yZ8aETxt+5lnPVX6MHKz -bfwI6nO1aMG6j9bSw+6UUyPBHP796+FT/pTS+K0wsDV7c9XvHoxJBJJU38cdLkI2 -c/i7lDqTfTcfLL2nyUBd2fQDk1B0fxrskhGIIZ3ifP1Ps4ltTkv8hRSob3VtNqSo -GxkKfvD2PKjTPxDPWYyruy9irLZioMffi3i/gCut0ZWtAyO3MVH5qWF/enKwgPES -X9po+TdCvRB/RUObBaM761EcrLSM1GqHNueSfqnho3AjLQ6dBnPWlo638Zm1VebK -BELyhkLWMSFkKwDmne0jQ02Y4g075vCKvCsCAwEAAaNjMGEwHQYDVR0OBBYEFH7R -4yC+UehIIPeuL8Zqw3PzbgcZMB8GA1UdIwQYMBaAFH7R4yC+UehIIPeuL8Zqw3Pz -bgcZMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgGGMA0GCSqGSIb3DQEB -CwUAA4IBAQBDNvD2Vm9sA5A9AlOJR8+en5Xz9hXcxJB5phxcZQ8jFoG04Vshvd0e -LEnUrMcfFgIZ4njMKTQCM4ZFUPAieyLx4f52HuDopp3e5JyIMfW+KFcNIpKwCsak -oSoKtIUOsUJK7qBVZxcrIyeQV2qcYOeZhtS5wBqIwOAhFwlCET7Ze58QHmS48slj -S9K0JAcps2xdnGu0fkzhSQxY8GPQNFTlr6rYld5+ID/hHeS76gq0YG3q6RLWRkHf -4eTkRjivAlExrFzKcljC4axKQlnOvVAzz+Gm32U0xPBF4ByePVxCJUHw1TsyTmel -RxNEp7yHoXcwn+fXna+t5JWh1gxUZty3 ------END CERTIFICATE----- -""" +GL_CA_CERT_URL = "https://certs.corp.redhat.com/certs/2022-IT-Root-CA.pem" _RATE_LIMIT_ERR_MSG = ( "rate limited by GitHub, set GITHUB_TOKEN env var and/or use GITHUB_API_URL " @@ -231,12 +207,10 @@ def fetch(self): @cached_property def _gl_certfile(self): with tempfile.NamedTemporaryFile(delete=False) as fp: - cert_fname = fp.name - fp.write(GL_CA_CERT.encode("ascii")) - - atexit.register(os.unlink, cert_fname) + urlretrieve(GL_CA_CERT_URL, fp.name) - return cert_fname + atexit.register(os.unlink, fp.name) + return fp.name @cached_property def _gh_auth_headers(self):