Skip to content

[Bug]: salt.utils.x509.load_pubkey param get_encoding is a no-op #70046

Closed

Description

@lkubb

What happened?

salt.utils.x509.load_pubkey does not account for the (thus unused) get_encoding parameter. Unsure why pylint didn't complain, but the parameter is never used internally. It should still be fixed.

See code:

salt/salt/utils/x509.py

Lines 818 to 853 in f52cede

def load_pubkey(pk, get_encoding=False):
"""
Return a public key instance from
* a class instance
* a file path on the local system
* a string (PEM)
* bytes (hex, base64, raw)
Valid encodings are PEM and DER.
"""
if hasattr(pk, "public_bytes"):
if isinstance(
pk,
(
rsa.RSAPublicKey,
ec.EllipticCurvePublicKey,
ed25519.Ed25519PublicKey,
ed448.Ed448PublicKey,
),
):
return pk
raise SaltInvocationError(
f"Passed object is not a public key, but {pk.__class__.__name__}"
)
pk = load_file_or_bytes(pk)
if PEM_BEGIN in pk:
try:
return serialization.load_pem_public_key(pk)
except ValueError as err:
raise PubDeserializationError(
"Could not load PEM-encoded public key."
) from err
try:
return serialization.load_der_public_key(pk)
except ValueError as err:
raise PubDeserializationError("Could not load DER-encoded public key.") from err

Type of salt install

Official deb

Major version

3006.x, 3007.x, 3008.x

What supported OS are you seeing the problem on? Can select multiple. (If bug appears on an unsupported OS, please open a GitHub Discussion instead)

ubuntu-24.04

salt --versions-report output

Latest HEAD of 3006.x

Activity

  1. added
    bug
    on Aug 14, 2026
  2. dwoz commented on Oct 16, 2026

    @dwoz
    Contributor

    This was fixed in v3006.28 and v3007.15. If you can still reproduce it on either release, please comment and we'll reopen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugneeds-triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions