From 87caac906e733e15ba3268db99f101bd1a93d9a1 Mon Sep 17 00:00:00 2001 From: Douglas Bagnall Date: Fri, 15 Aug 2025 17:35:33 +1200 Subject: [PATCH] py:key_credential_links: allow encoding=='auto' 'auto' is the same as None. This is helpful to samba-tool. Signed-off-by: Douglas Bagnall Reviewed-by: Gary Lockyer --- python/samba/key_credential_link.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/python/samba/key_credential_link.py b/python/samba/key_credential_link.py index b17581bf46d..64bca98b946 100644 --- a/python/samba/key_credential_link.py +++ b/python/samba/key_credential_link.py @@ -195,7 +195,7 @@ class KeyCredentialLinkDn(BinaryDn): return pem.decode() -def get_public_key(data:bytes, encoding:str): +def get_public_key(data:bytes, encoding:Optional[str] = None) -> RSAPublicKey: """decode a key in PEM or DER format. If it turns out to be a certificate or something, we try to get @@ -268,6 +268,9 @@ def create_key_credential_link(samdb: SamDB, if len(res) == 0: raise ValueError(f"link target {target} does not exist") + if encoding == 'auto': + encoding = None + key = get_public_key(data, encoding) if key.key_size != 2048: -- 2.47.3