Getting 'incorrect padding' error while running 'subscription-manager' commands.

Solution Verified - Updated -

Environment

  • Red Hat Enterprise Linux 7.1
  • Red Hat Subscription Manager

Issue

  • Every time subscription-manager command is executed, we get an error 'incorrect padding' error message.

  • Getting 'Incorrect padding' error message as follows:

# subscription-manager remove --all
0 subscriptions removed at the server.
Incorrect padding

Resolution

# yum update coreutils
  • Coreutils (base64) is an encoder/decoder which reads a block of input to a buffer, transforms it, and writes it out.

Root Cause

  • The trackback errors shows incompatibility between the O.S. and the subscription-manager as base64-encoded strings are not getting decrypted as required.

Diagnostic Steps

Check for /var/log/rhsm/rhsm.log file to see the python trackback errors:

exception caught while running <subscription_manager.repolib.RepoActionInvoker object at 0xe9fdd0> update
2019-02-18 08:51:28,643 [ERROR] rhsmcertd-worker @base_action_client.py:73 - Incorrect padding Traceback (most recent call last):
  File "/usr/share/rhsm/subscription_manager/base_action_client.py", line 63, in _run_update
    update_report = lib.update()
  File "/usr/share/rhsm/subscription_manager/certlib.py", line 31, in update
    self.report = self.locker.run(self._do_update)
  File "/usr/share/rhsm/subscription_manager/certlib.py", line 17, in run
    return action()
  File "/usr/share/rhsm/subscription_manager/repolib.py", line 53, in _do_update
    action = RepoUpdateActionCommand(cache_only=self.cache_only)
  File "/usr/share/rhsm/subscription_manager/repolib.py", line 184, in _init_
    self.ent_source = ent_cert.EntitlementDirEntitlementSource()
  File "/usr/share/rhsm/subscription_manager/model/ent_cert.py", line 70, in _init_
    for ent_cert in ent_dir.list_valid():
  File "/usr/share/rhsm/subscription_manager/certdirectory.py", line 293, in list_valid
    for c in self.list():
  File "/usr/share/rhsm/subscription_manager/certdirectory.py", line 121, in list
    listing.append(create_from_file(path))
  File "/usr/lib64/python2.7/site-packages/rhsm/certificate.py", line 59, in create_from_file
    return _CertFactory().create_from_file(path)
  File "/usr/lib64/python2.7/site-packages/rhsm/certificate2.py", line 66, in create_from_file
    return self._read_x509(_certificate.load(path), path, pem)
  File "/usr/lib64/python2.7/site-packages/rhsm/certificate2.py", line 100, in _read_x509
    raise CertificateException(str(e))
CertificateException: Incorrect padding
2019-02-18 08:51:28,644 [DEBUG] rhsmcertd-worker @plugins.py:569 - loaded plugin modules: []
2019-02-18 08:51:28,644 [DEBUG] rhsmcertd-worker @plugins.py:570 - loaded plugins: {}
2019-02-18 08:51:28,644 [ERROR] rhsmcertd-worker @certificate2.py:99 - Incorrect padding Traceback (most recent call last):
  File "/usr/lib64/python2.7/site-packages/rhsm/certificate2.py", line 94, in _read_x509
    return self._create_v3_cert(version, extensions, x509, path, pem)
  File "/usr/lib64/python2.7/site-packages/rhsm/certificate2.py", line 258, in _create_v3_cert
    payload = self._decompress_payload(base64.b64decode(entitlement_data))
  File "/usr/lib64/python2.7/base64.py", line 76, in b64decode
    raise TypeError(msg)
TypeError: Incorrect padding

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.