Skip to content

Commit 3c8c0f8

Browse files
committed
Add keytype parameter in keybundle_from_local_file
1 parent e01937c commit 3c8c0f8

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/cryptojwt/key_bundle.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -636,21 +636,25 @@ def difference(self, bundle):
636636
return [k for k in self._keys if k not in bundle]
637637

638638

639-
def keybundle_from_local_file(filename, typ, usage):
639+
def keybundle_from_local_file(filename, typ, usage, keytype="RSA"):
640640
"""
641641
Create a KeyBundle based on the content in a local file.
642642
643643
:param filename: Name of the file
644644
:param typ: Type of content
645645
:param usage: What the key should be used for
646+
:param keytype: Type of key, e.g. "RSA", "EC". Only used with typ='der'
646647
:return: The created KeyBundle
647648
"""
648649
usage = harmonize_usage(usage)
649650

650651
if typ.lower() == "jwks":
651652
_bundle = KeyBundle(source=filename, fileformat="jwks", keyusage=usage)
652-
elif typ.lower() == 'der':
653-
_bundle = KeyBundle(source=filename, fileformat="der", keyusage=usage)
653+
elif typ.lower() == "der":
654+
_bundle = KeyBundle(source=filename,
655+
fileformat="der",
656+
keyusage=usage,
657+
keytype=keytype)
654658
else:
655659
raise UnknownKeyType("Unsupported key type")
656660

0 commit comments

Comments
 (0)