Missing /etc/pki/consumer/cert.pem cannot register EL8

Problem:
In the last weeks when trying to register new servers to my activation keys and content views, at the registration moment, and after being able to install the katello-ca-consumer-latest.noarch.rpm, the registration ends with an error, and I’m just able to overcome this issue with placing insecure =
1 on /etc/rhsm/rhsm.conf.

Although, this troubleshoot has been done with no success

update-crypto-policies --set DEFAULT

Expected outcome:
Host is being registered.

Foreman and Proxy versions:
3.5.1

Foreman and Proxy plugin versions:
foreman-tasks 7.1.1
foreman_ansible 10.4.0
foreman_remote_execution 8.2.0
katello 4.7.2

Distribution and version:
Oracle Linux 8.7

Other relevant data:
/var/log/rhsm/rhsm.log
2023-06-20 15:54:02,913 [ERROR] subscription-manager:20482:MainThread @cli.py:60 - Error during registration: Error loading certificate: [Errno 2] No such file or directory: ‘/etc/pki/consumer/cert.pem’
2023-06-20 15:54:02,913 [ERROR] subscription-manager:20482:MainThread @cli.py:61 - Error loading certificate: [Errno 2] No such file or directory: ‘/etc/pki/consumer/cert.pem’
Traceback (most recent call last):
File “/usr/lib64/python3.6/site-packages/rhsm/connection.py”, line 745, in _request
conn.request(request_type, handler, body=body, headers=final_headers)
File “/usr/lib64/python3.6/http/client.py”, line 1273, in request
self._send_request(method, url, body, headers, encode_chunked)
File “/usr/lib64/python3.6/http/client.py”, line 1319, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File “/usr/lib64/python3.6/http/client.py”, line 1268, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File “/usr/lib64/python3.6/http/client.py”, line 1044, in _send_output
self.send(msg)
File “/usr/lib64/python3.6/http/client.py”, line 982, in send
self.connect()
File “/usr/lib64/python3.6/http/client.py”, line 1441, in connect
server_hostname=server_hostname)
File “/usr/lib64/python3.6/ssl.py”, line 365, in wrap_socket
_context=self, _session=session)
File “/usr/lib64/python3.6/ssl.py”, line 776, in init
self.do_handshake()
File “/usr/lib64/python3.6/ssl.py”, line 1036, in do_handshake
self._sslobj.do_handshake()
File “/usr/lib64/python3.6/ssl.py”, line 648, in do_handshake
self._sslobj.do_handshake()
ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:897)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/usr/lib64/python3.6/site-packages/rhsm/certificate2.py”, line 67, in create_from_file
pem = open(path, ‘r’).read()
FileNotFoundError: [Errno 2] No such file or directory: ‘/etc/pki/consumer/cert.pem’

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/usr/lib64/python3.6/site-packages/subscription_manager/cli_command/register.py”, line 234, in _do_command
environment_ids = self._process_environments(admin_cp, owner_key)
File “/usr/lib64/python3.6/site-packages/subscription_manager/cli_command/register.py”, line 337, in _process_environments
supported_resources = get_supported_resources()
File “/usr/lib64/python3.6/site-packages/subscription_manager/utils.py”, line 212, in get_supported_resources
return uep.get_supported_resources()
File “/usr/lib64/python3.6/site-packages/rhsm/connection.py”, line 1022, in get_supported_resources
self._load_supported_resources()
File “/usr/lib64/python3.6/site-packages/rhsm/connection.py”, line 1010, in _load_supported_resources
resources_list = self.conn.request_get(“/”)
File “/usr/lib64/python3.6/site-packages/rhsm/connection.py”, line 929, in request_get
return self._request(“GET”, method, headers=headers, cert_key_pairs=cert_key_pairs)
File “/usr/lib64/python3.6/site-packages/rhsm/connection.py”, line 962, in _request
info=info, headers=headers, cert_key_pairs=cert_key_pairs)
File “/usr/lib64/python3.6/site-packages/rhsm/connection.py”, line 764, in _request
id_cert = certificate.create_from_file(self.cert_file)
File “/usr/lib64/python3.6/site-packages/rhsm/certificate.py”, line 53, in create_from_file
return _CertFactory().create_from_file(path)
File “/usr/lib64/python3.6/site-packages/rhsm/certificate2.py”, line 69, in create_from_file
raise CertificateException(“Error loading certificate: %s” % err)
rhsm.certificate.CertificateException: Error loading certificate: [Errno 2] No such file or directory: ‘/etc/pki/consumer/cert.pem’

Hi,
if you register host by registration command in Hosts > Register it should take care of the certificate.

1 Like

I’ve done this workaround and it doesn’t work, the only thing that works, is to edit rhsm.conf and set the insecure value to 1.

Is there any other thing besides the rhsm.conf editing thing, to solve this issue?