Installing packages with yum failed with error "unable to get local issuer certificate"

When installing packages or performing yum repolist:

# vi /var/log/dnf.log
2023-06-14T21:47:23-0400 DEBUG error: Curl error (60): Peer certificate cannot be authenticated with given CA certificates for https://www.example.com/content/dist/layered/rhel8/x86_64/ansible/2.9/os/repodata/repomd.xml [SSL certificate problem: unable to get local issuer certificate] (https://www.example.com/content/dist/layered/rhel8/x86_64/ansible/2.9/os/repodata/repomd.xml).
2023-06-14T21:47:23-0400 WARNING Errors during downloading metadata for repository 'rhosp-ansible-2.9':
  - Curl error (60): Peer certificate cannot be authenticated with given CA certificates for https://www.example.com/content/dist/layered/rhel8/x86_64/ansible/2.9/os/repodata/repomd.xml [SSL certificate problem: unable to get local issuer certificate]

This could be caused by self-signed certificate.

There are 2 options as workaround:

Option 1), For one repo you can add the following in the repo configuration:

sslverify=0

Option 2), For all repos, you can add the following to “/etc/yum.conf”:

sslverify=false
Written on June 15, 2023