Skip to content

Commit

Permalink
Create directory as needed.
Browse files Browse the repository at this point in the history
  • Loading branch information
rohe committed Jan 24, 2020
1 parent 64515a9 commit b957d6f
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/cryptojwt/jwk/jwk.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,10 @@ def jwk_wrap(key, use="", kid=""):

def dump_jwk(filename, key):
"""Writes a RSAKey, ECKey or SYMKey instance as a JWK to a file."""
head, tail = os.path.split(filename)
if head and not os.path.isdir(head):
os.makedirs(head)

with open(filename, 'w') as fp:
fp.write(json.dumps(key.to_dict()))

Expand Down

0 comments on commit b957d6f

Please sign in to comment.