This bug has been migrated to another issue tracking site. It has been closed here and may no longer be being monitored.

If you would like to get updates for this issue, or to participate in it, you may do so at Red Hat Issue Tracker .
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 2025478 - osbuild-composer fails when multiple custom repos are defined on the Satellite server
Summary: osbuild-composer fails when multiple custom repos are defined on the Satellit...
Keywords:
Status: CLOSED MIGRATED
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: osbuild-composer
Version: 8.5
Hardware: All
OS: Linux
high
high
Target Milestone: rc
: ---
Assignee: Image Builder team
QA Contact: Release Test Team
URL:
Whiteboard:
: 2043717 (view as bug list)
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2021-11-22 10:37 UTC by Christophe Besson
Modified: 2023-09-18 12:06 UTC (History)
9 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2023-09-18 12:03:40 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker COMPOSER-1939 0 None None None 2023-03-27 14:34:37 UTC
Red Hat Issue Tracker   RHEL-4558 0 None Migrated None 2023-09-18 12:03:39 UTC
Red Hat Issue Tracker RHELPLAN-103536 0 None None None 2021-11-22 10:41:31 UTC
Red Hat Knowledge Base (Article) 7004689 0 None None None 2023-03-28 13:30:11 UTC

Description Christophe Besson 2021-11-22 10:37:30 UTC
Description of problem:
This bug was originally described in:
https://bugzilla.redhat.com/show_bug.cgi?id=1945670

But the customer is still encountering the issue after applying the below errata, fixing rhbz#1896185:
https://access.redhat.com/errata/RHBA-2021:4273

Version-Release number of selected component (if applicable):
osbuild-composer-33.2-1.el8.x86_64
osbuild-35-3.el8.noarch

How reproducible:
Always

Steps to Reproduce:
See the reproducer in the original BZ, multiple custom Satellite being required.
Use the below procedure to setup the overrides:
https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/composing_a_customized_rhel_system_image/managing-repositories_composing-a-customized-rhel-system-image#overriding-a-system-repository_managing-repositories

In the outlines, they followed the steps below:

# mkdir -p /etc/osbuild-composer/repositories
# cp /usr/share/osbuild-composer/repositories/rhel-85.json /etc/osbuild-composer/repositories/
# URL=$(dnf repolist -v 2>&1 | awk '/baseurl/ {print $3}' | grep baseos/os | head -n1 | sed 's|dist/.*||')
# sed -i "s|https://cdn.redhat.com/content/|$URL|" /etc/osbuild-composer/repositories/rhel-85.json
# sed -i "s|rhel8/8.5|rhel8/8|" /etc/osbuild-composer/repositories/rhel-85.json        ### if needed
# rm -rf /var/cache/osbuild-composer/*
# cd /etc/rhsm/ca
# mv redhat-uep.pem redhat-uep.pem.bak
# ln -s katello-server-ca.pem redhat-uep.pem
# systemctl restart osbuild-composer

Note the Satellite CACert has been symlinked from the CDN one (redhat-uep.pem) because the composer was always looking for this file.

Actual results:

From the journal:
Nov 18 17:02:16 <HOSTNAME> osbuild-composer[27834]: 2021/11/18 17:02:16 GET /api/v1/blueprints/depsolve/MyImage1
Nov 18 17:02:16 <HOSTNAME> osbuild-composer[27834]: Errors during downloading metadata for repository '0':
Nov 18 17:02:16 <HOSTNAME> osbuild-composer[27834]:   - Status code: 403 for https://<CUSTOM_SAT_URL>/content/dist/rhel8/8/x86_64/baseos/os/repodata/repomd.xml (IP: <CUSTOM_IP>)

From the strace:
$ grep openat\(.*pem 0100-sat-composer.tgz/tmp/composer.strace | grep -v ENOENT
27917 17:02:16.812477 openat(AT_FDCWD, "/etc/pki/entitlement/3665926663619286915.pem", O_RDONLY) = 10</etc/pki/entitlement/3665926663619286915.pem> <0.000065>
27917 17:02:16.813055 openat(AT_FDCWD, "/etc/pki/entitlement/3665926663619286915-key.pem", O_RDONLY) = 10</etc/pki/entitlement/3665926663619286915-key.pem> <0.000029>
27917 17:02:16.813455 openat(AT_FDCWD, "/etc/rhsm/ca/redhat-uep.pem", O_RDONLY) = 10</etc/rhsm/ca/katello-server-ca.pem> <0.000133>

From redhat.repo:
[rhel-8-for-x86_64-baseos-rpms]
name = Red Hat Enterprise Linux 8 for x86_64 - BaseOS (RPMs)
baseurl = https://<CUSTOM_SAT_URL>/content/dist/rhel8/$releasever/x86_64/baseos/os
 :
sslcacert = /etc/rhsm/ca/katello-server-ca.pem
sslclientkey = /etc/pki/entitlement/6874917509862528732-key.pem
sslclientcert = /etc/pki/entitlement/6874917509862528732.pem


Expected results:
The right key/pair corresponding to baseos/appstream is used.

Additional info:
# grep rhsm /etc/osbuild-composer/repositories/rhel-85.json | sort -u
            "rhsm": true,

# composer-cli sources info baseos
[baseos]
name = "baseos"
type = "yum-baseurl"
url = "https://<CUSTOM_SAT_URL>/dist/rhel8/8/x86_64/baseos/os"
check_gpg = true
check_ssl = true
system = true
rhsm = false                    <===

Comment 1 Martin Sehnoutka 2021-11-22 11:28:26 UTC
Regarding the steps:
Please do not symlink redhat-uep.pem any more. osbuild-composer is looking for it because there is an edge case for subscriptions with simple content access. This is used, for example, when building cross-distro images but in the usual use case the certificate is loaded but not used.
(Ref. upstream: https://github.com/osbuild/osbuild-composer/pull/1405/commits/0e613daa157f241d7a02e88deecb32366f4a5c0d)

Now I can see two different issues in your bug report. Please correct me if I got this wrong:

1. osbuild-composer loads /etc/pki/entitlement/3665926663619286915.pem but it should load /etc/pki/entitlement/6874917509862528732.pem (and corresponding key of course).
2. the repository override in /etc/osbuild-composer/repositories/rhel-85.json specifies rhsm: "true", but composer-cli reports rhsm = false

I believe the first issue is the pressing one. It would be great if you could share the repo override and redhat.repo files with me. If not, is there an entry in redhat.repo file that actually uses the certificate /etc/pki/entitlement/3665926663619286915.pem? I would like to see how it compares to the URL https://<CUSTOM_SAT_URL>/dist/rhel8/8/x86_64/baseos/os. It is possible that the algorithm is somehow confusing these two URLs. If that is the case, we need to update the implementation.

Thanks.

Comment 2 Christophe Besson 2021-11-22 11:40:57 UTC
I suggested this because it helped going a little bit further.

In my reproducer I had the following error when I don't make the symlink:

Nov 17 15:06:16 <HOSTNAME> osbuild-composer[16493]:   - Curl error (60): Peer certificate cannot be authenticated with given CA certificates for https://<INTERNAL_SAT_HOSTNAME>/pulp/repos/JJAN_ORG/Library/RHEL8/content/dist/rhel8/8.5/x86_64/baseos/os/repodata/repomd.xml [SSL certificate problem: self signed certificate in certificate chain]

I thought this and the fact there is an issue with the key/pair association were both related to 'rhsm = false' seen by the composer.

I answer yes to your both questions.

Attaching a tarball as private with all you need.

Comment 5 Martin Sehnoutka 2021-11-24 11:47:49 UTC
(In reply to Christophe Besson from comment #2)
> I suggested this because it helped going a little bit further.
> 
> In my reproducer I had the following error when I don't make the symlink:
> 
> Nov 17 15:06:16 <HOSTNAME> osbuild-composer[16493]:   - Curl error (60):
> Peer certificate cannot be authenticated with given CA certificates for
> https://<INTERNAL_SAT_HOSTNAME>/pulp/repos/JJAN_ORG/Library/RHEL8/content/
> dist/rhel8/8.5/x86_64/baseos/os/repodata/repomd.xml [SSL certificate
> problem: self signed certificate in certificate chain]

I'm suspicious about this URL:
https://<INTERNAL_SAT_HOSTNAME>/pulp/repos/JJAN_ORG/Library/RHEL8/content/dist/rhel8/8.5/x86_64/baseos/os/repodata/repomd.xml
is it possible that the URL is written like this in redhat.repo file?
https://<INTERNAL_SAT_HOSTNAME>/pulp/repos/JJAN_ORG/Library/RHEL8/content/dist/rhel8/$releasever/x86_64/baseos/os/repodata/repomd.xml
if yes, it would make osbuild-composer assume the URL looks like this
https://<INTERNAL_SAT_HOSTNAME>/pulp/repos/JJAN_ORG/Library/RHEL8/content/dist/rhel8/8/x86_64/baseos/os/repodata/repomd.xml
so it wouldn't be able to match the keys.

Can you have a look please?

Also if it was the case, where does the $releasever value come from? Is it defined in /etc/dnf/vars or does it come from redhat-release package (rpm -q --provides redhat-release)?

> 
> I thought this and the fact there is an issue with the key/pair association
> were both related to 'rhsm = false' seen by the composer.
> 
> I answer yes to your both questions.
> 
> Attaching a tarball as private with all you need.

Comment 6 Christophe Besson 2021-11-24 14:59:30 UTC
I can't access anymore to this machine which has been shared by a colleague from the Satellite team, but I can access another one with a similar configuration.

I confirm $releasever is present very frequently in redhat.repo, and this variable can come from at least 2 places.

1) /etc/dnf/vars/releasever but this is manual and not frequent
2) /var/lib/rhsm/cache/releasever.json, by default it is "null", which means the release is not locked to a specific version (i.e. 8.5), in this case the baseurl contains $releasever, which is expanded at runtime to rhel8/8 (the latest). If the release is locked with `subscription-manager release --set=8.5`, the $releasever appears to be directly expanded / hardcoded into the redhat.repo file.

From my understanding, the simple way to check the "expansion" of $releasever is to run a `dnf repolist -v`.
Please note this is only an observation.

It would greatly help to have an option telling to use the host repositories without entering into such details, as it is error-prone, and it will cause issues after a RHEL minor version upgrade (for the baseurls, but also for the repo overrides filename). If this is not difficult to implement, maybe an helper tool to create this configuration.

Comment 7 Christophe Besson 2021-11-24 15:35:02 UTC
I forgot to tell your suspicion is correct, the issue is reproducible on this new machine when redhat.repo contains the variable (when the release is locked), but not when the release is locked (with redhat.repo hardcoded with the version). It seems it picks up the right key pair, whereas there are other custom repos (with the key pair of baseos/appstream not coming first, alphanumerically speaking).
And it chooses the right cacert (katello-server).

That means we have a workaround, locking the release to "8" (latest) or "8.5", depending on the repos configured on the Satellite server (sometimes it does not have both).

Thanks!

Comment 8 Christophe Besson 2021-11-24 15:37:25 UTC
Correcting a typo to avoid confusion.

I forgot to tell your suspicion is correct, the issue is reproducible on this new machine when redhat.repo contains the variable (when the release is _NOT_ locked), but not when the release is locked (with redhat.repo hardcoded with the version). It seems it picks up the right key pair, whereas there are other custom repos (with the key pair of baseos/appstream not coming first, alphanumerically speaking).
And it chooses the right cacert (katello-server).

That means we have a workaround, locking the release to "8" (latest) or "8.5", depending on the repos configured on the Satellite server (sometimes it does not have both).

Thanks!

Comment 9 Martin Sehnoutka 2021-11-25 09:36:54 UTC
I'm glad there is a fairly simple solution. I'll arrange a knowledge-base article about this.

Thank you! :)

Regarding the usage of system repos and/or a helper tool: We want to improve the repository management. It is complicated by the fact that composer can build different distributions than the host system and also it can have multiple worker process distributed across multiple hosts all connecting to a single composer instance. But thanks for your feedback, it is good to know that there is an interest in using system repositories directly.

Comment 10 Christophe Besson 2021-11-25 10:01:35 UTC
I planned to do the KCS after the confirmation of the customer that it fixes the issue for them.
I'll link it to the BZ afterwards, feel free to review/modify it once I shared it.

Comment 11 Martin Sehnoutka 2021-11-25 11:03:24 UTC
Ok, perfect, thanks!

Comment 13 Christophe Besson 2021-11-25 16:01:08 UTC
Sorry to come with bad news, $releasever has been hardcoded but the issue still occurs for the customer.
However, it is a true issue since it is there by default on Satellite clients, and I can easily reproduce.

In the fresh attachment above, they initially got a "SSL certificate problem: self signed certificate in certificate chain" error, and retried the cacert symlink to go further. They still get a 403 error after that, indicating the wrong key pair is used (the fallback code).

Comment 14 Martin Sehnoutka 2021-11-29 12:07:27 UTC
That is not a good news. I'm trying to reproduce the issue, but so far it seems to pick the right key for me.

The fallback code is not going to work in environment where multiple keys are present in /etc/pki/entitlement. It pick the first one sorted alphabetically so unless the right key is the first one, it will fail.

Thanks for the new attachment and I'll keep you updated.

Comment 22 Thomas Juberg 2022-02-17 19:52:06 UTC
We are also hitting this issue.

We have a primary composite view that includes RHEL repos, Zabbix Repos, Treasure Data agent repos and EPEL repos. This gives us a total of 4 subscriptions related to our base content view, and as such, 4 sets of keys in /etc/pki/entitlement.

403 errors occur as long as all keys are present. If I remove the subscriptions for everything but RHEL it works as there is only key present, but I loose access to repos containing packages I need.

Comment 23 Ondřej Budai 2022-03-01 14:24:58 UTC
*** Bug 2043717 has been marked as a duplicate of this bug. ***

Comment 25 kechoi 2022-05-27 00:17:17 UTC
msehnout is correct in comment #1 about there being two issues.
I've verified with a CSS customer that the below two solutions resolves the SSL issues:
1) Placing the .pem file(s) in the /usr/share/pki/ca-trust-source/anchors/ directory fixes the SSL issue, specifically the `Curl error (60): Peer certificate cannot be authenticated with given CA certificates for https://<CUSTOM_SAT_URL>/content/dist/rhel8/8/x86_64/baseos/os/repodata/repomd.xml [SSL certificate problem: self signed certificate in certificate chain]` error for CSS customer.
Got this from KCS article: https://access.redhat.com/solutions/5773421, which looks like it will also fix the 403 error noted in the bug description.

2) Locking the release to a specific minor version resolved another SSL error, `osbuild-worker[30358]: osbuild.host.RemoteError: RuntimeError: curl: error downloading {'url': 'https://<CUSTOM_SAT_URL>/content/dist/rhel8/$releasever/x86_64/baseos/os/Packages/<path-to-rpm>', 'secrets': {'ssl_ca_cert': '/etc/rhsm/ca/katello-server-ca.pem', 'ssl_client_key': '/etc/pki/entitlement/<num>-key.pem ', 'ssl_client_cert': '/etc/pki/entitlement/<num>.pem'}}: error code 22`

Comment 27 Christophe Besson 2023-02-25 11:08:58 UTC
Adding again the last case (03421267).
It wouldn't have fail if the customer didn't have multiple keys (for multiple repos).

Symptom:
A CA cert error or an HTTP 403 error while trying to depsolve.
After checking the configuration, the JSON repo overrides are properly defined.

The issue can be seen in the osbuild-worker@1 log:
Curl error (60): Peer certificate cannot be authenticated with given CA certificates for https://XXXXXXXXX/RHEL8/content/dist/rhel8/8/x86_64/baseos/os/repodata/repomd.xml [SSL certificate problem: self signed certificate in certificate chain]

Usually the support suggests to symlink the RH cacert to point to the Sat/Katello one to workaround the issue.
But that will work only if there is only one key pair in /etc/pki/entitlement.

The strace confirms the worker didn't pick up the right key pair (it seems it has chosen the first alphanumerically and it was unlucky...), explaining the issue, that becomes:
Status code: 403 for https://XXXXXXXXXXXXXXXX/Dev/RHEL8/content/dist/rhel8/8/x86_64/baseos/os/repodata/repomd.xml 

The strace also shows /etc/yum.repos.d/redhat.repo permissions were too restrictive:
openat(AT_FDCWD</usr/libexec/osbuild-composer>, "/etc/yum.repos.d/redhat.repo", O_RDONLY|O_CLOEXEC) = -1 EACCES (Permission denied) <0.000064>

# namei -l /etc/yum.repos.d/redhat.repo
f: /etc/yum.repos.d/redhat.repo
dr-xr-xr-x root root /
drwxr-xr-x root root etc
drwxr-xr-x root root yum.repos.d
-rw-r----- root root redhat.repo            <<<<

Fixing the perms from 0640 to 0644 resolved the issue for this customer.
osbuild-composer should report that EACCES and not ignore it.

Comment 28 Christophe Besson 2023-03-21 15:08:09 UTC
Adding another use case for this problem.

The customer has configured a custom repo on its Satellite server, hence they have 2 key pairs in /etc/pki/entitlement.
Unfortunately, the custom repo comes with the first key pair, alphanumerically speaking.

They use RHEL 8.7 with the latest osbuild* versions:
osbuild-65-1.el8
osbuild-composer-62-3.el8_7

They correctly configured repo overrides, and that works for RHEL 8.7 but when they choose another distro from the blueprint ("rhel-86"), that does not work:

# composer-cli blueprints depsolve RHEL8.6
ERROR: BlueprintsError: RHEL8.6: DNF error occurred: RepoError: There was a problem reading a repository: Failed to download metadata for repo '59df49401dd00ec6d5141c3077df6abe32c4eef3752a0c100b4d105a06c67e08' [baseos: https://XXX/pulp/content/XXX/Library/content/dist/rhel8/8.6/x86_64/baseos/os/]: Cannot download repomd.xml: Cannot download repodata/repomd.xml: All mirrors were tried
blueprint: RHEL8.6 v0.0.1

This is because the baseurl from /etc/yum.repos.d/redhat.repo (with $releasever hardcoded or not) does not match, and in this case osbuild-composer is not able to choose which key pair to choose, and always choose the first one in this case, leading to a CAcert error (using redhat cacert instead of the Satellite one) or a 403 error if the limited "workaround" always given by the support is done (a symlink from /etc/rhsm/ca/redhat-uep.pem to /etc/rhsm/ca/katello-server-ca.pem as explained in https://access.redhat.com/solutions/5773421).

Steps to reproduce easily without a Satellite server:

1. Install a fresh RHEL 8.7
2. Simulate another repo by just touching a new key pair that will come at first, alphanumerically

    # touch /etc/pki/entitlement/{000,000-key}.pem

3. Create a blueprint with distro = "rhel-86" and try to depsolve it.


The number of cases attached to this BZ does not reflect the number of customers impacted by this issue, as it can take several forms, and the symlink workaround hides the issue as long as there is only one key pair on the system.

Comment 29 Christophe Besson 2023-03-22 16:07:26 UTC
Suggested workaround that worked for the custy.

Generate a debug certificate from your Satellite server.
The idea is to follow the 3.3 and 3.4 prerequisites sections from:

https://access.redhat.com/documentation/en-us/red_hat_satellite/6.11/html/managing_content/managing_organizations_content-management#Creating_an_Organization_Debug_Certificate_content-management

Quoting the doc:

In the Satellite web UI, navigate to Administer > Organizations.
Select an organization that you want to generate a debug certificate for.
Click Generate and Download.
Save the certificate file in a secure location. 

Open the X.509 certificate, for example, for the default organization:
$ vi 'Default Organization-key-cert.pem'

Copy the contents of the file from -----BEGIN RSA PRIVATE KEY----- to -----END RSA PRIVATE KEY-----, into a key.pem file.
Copy the contents of the file from -----BEGIN CERTIFICATE----- to -----END CERTIFICATE-----, into a cert.pem file.

Ensure at first it works for you with curl, as explained in §3.4 - "for curl users":

# curl -O -v --cert cert.pem --key key.pem --cacert /etc/rhsm/ca/katello-server-ca.pem https://XXX/pulp/content/XXX/content/dist/rhel8/8.6/x86_64/baseos/os/repodata/repomd.xml

If you get an HTTP 200 return code, that means the metadata repomd.xml is properly downloaded.
If it works, you can then overwrite all the keys from /etc/pki/entitlement with key.pem and all the certs (the pem files without "-key") with cert.pem.
Finally, make the pem files immutable to be sure they're not overwritten by rhsmcertd:

# chattr +i /etc/pki/entitlement/*

Comment 30 RHEL Program Management 2023-09-18 12:02:02 UTC
Issue migration from Bugzilla to Jira is in process at this time. This will be the last message in Jira copied from the Bugzilla bug.

Comment 31 RHEL Program Management 2023-09-18 12:03:40 UTC
This BZ has been automatically migrated to the issues.redhat.com Red Hat Issue Tracker. All future work related to this report will be managed there.

Due to differences in account names between systems, some fields were not replicated.  Be sure to add yourself to Jira issue's "Watchers" field to continue receiving updates and add others to the "Need Info From" field to continue requesting information.

To find the migrated issue, look in the "Links" section for a direct link to the new issue location. The issue key will have an icon of 2 footprints next to it, and begin with "RHEL-" followed by an integer.  You can also find this issue by visiting https://issues.redhat.com/issues/?jql= and searching the "Bugzilla Bug" field for this BZ's number, e.g. a search like:

"Bugzilla Bug" = 1234567

In the event you have trouble locating or viewing this issue, you can file an issue by sending mail to rh-issues. You can also visit https://access.redhat.com/articles/7032570 for general account information.


Note You need to log in before you can comment on or make changes to this bug.