From e1311c029501fac714e42c63e6f75ab5ea608924 Mon Sep 17 00:00:00 2001 From: Sanne Raymaekers Date: Fri, 3 Sep 2021 19:27:10 +0200 Subject: [PATCH 1/2] util/rhsm: Check if repositories is None before iterating When `get_fallback_rhsm_secrets` was used, `Subscriptions.repositories` was None, and `get_secrets` never returned the fallback secrets. So check if `repositories` is None before iterating over it, otherwise return the fallback secrets. --- osbuild/util/rhsm.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/osbuild/util/rhsm.py b/osbuild/util/rhsm.py index 21a2d50..3ab1729 100644 --- a/osbuild/util/rhsm.py +++ b/osbuild/util/rhsm.py @@ -93,13 +93,14 @@ class Subscriptions: def get_secrets(self, url): # Try to find a matching URL from redhat.repo file first - for parameters in self.repositories.values(): - if parameters["matchurl"].match(url) is not None: - return { - "ssl_ca_cert": parameters["sslcacert"], - "ssl_client_key": parameters["sslclientkey"], - "ssl_client_cert": parameters["sslclientcert"] - } + if self.repositories is not None: + for parameters in self.repositories.values(): + if parameters["matchurl"].match(url) is not None: + return { + "ssl_ca_cert": parameters["sslcacert"], + "ssl_client_key": parameters["sslclientkey"], + "ssl_client_cert": parameters["sslclientcert"] + } # In case there is no matching URL, try the fallback if self.secrets: -- 2.31.1