Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shouldn't jwk.import_from_pyca also provide a kid param and set it to thumbprint() by default? #332

Open
matgnt opened this issue Oct 24, 2023 · 2 comments

Comments

@matgnt
Copy link

matgnt commented Oct 24, 2023

When importing from a pem file (import_from_pem), the kid can be set or if not, it uses the thumbprint() by default.
Especially when the jwk is added to a jwks afterwards - and potentially multiple keys are in the jwks, a kid would be required to identify the right key.

self.__setitem__('kid', kid)

Example workaround:

    pub_jwk.import_from_pyca(pub_key)
    pub_jwk['kid'] = pub_jwk.thumbprint()
    jwks = JWKSet()
    jwks.add(pub_jwk)
    jwks_export = jwks.export(private_keys=False, as_dict=True)

Anything I'm doing wrong here?
Thanks,
Matthias

@simo5
Copy link
Member

simo5 commented Oct 24, 2023

I do not understand what the question is.
The code will set the thumbprint() as the 'kid' if an explicit kid is not provided to import_from_pem().

But in your example you are calling import_from_pyca() which is a different function ...

When importing from raw keys thre is no automatic setting of the 'kid' parameter.

Is this a feature request to add a kid=None parameter to import_from_pyca(), and automatically set kid to self.thumbprint() when kid is not explicitly provided?

@matgnt
Copy link
Author

matgnt commented Oct 24, 2023

Is this a feature request to add a kid=None parameter to import_from_pyca(), and automatically set kid to self.thumbprint() when kid is not explicitly provided?

Yes, correct.

Because I used the pem import first, I was confused why I didn't see the kid in my JWKS exports when I changed code to import from pyca.

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

No branches or pull requests

2 participants