From: Douglas Bagnall Date: Fri, 15 Aug 2025 05:35:33 +0000 (+1200) Subject: py:key_credential_links: allow encoding=='auto' X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=87caac906e733e15ba3268db99f101bd1a93d9a1;p=thirdparty%2Fsamba.git 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 --- 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: