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

Add support to decode RSA public key generated using ssh-keygen #7505

Open
ayeshLK opened this issue Jan 17, 2025 · 1 comment
Open

Add support to decode RSA public key generated using ssh-keygen #7505

ayeshLK opened this issue Jan 17, 2025 · 1 comment

Comments

@ayeshLK
Copy link
Member

ayeshLK commented Jan 17, 2025

Current Limitation

Currently Ballerina crypto module does not support the public-key format generated with ssh-keygen

Suggested Improvement

We need to include add support to decode public-keys generated with ssh-keygen

Steps

  1. Generate the key-pair using ssh-keygen
ssh-keygen -t rsa -b 4096 -m PEM -f private.key

With the above command two files will be generated private.key and private.key.pub (which is the public key)

  1. Try to decode the public-key using Ballerina crypto module
crypto:PublicKey publicKey = check crypto:decodeRsaPublicKeyFromCertFile("<path-to>/private.key.pub")
@isamauny
Copy link

isamauny commented Jan 18, 2025

Sorry but this is not my requirement :) My requirement is to be able to validate a JWT using a single JWK - This works for HS (symmetric) and RS/EC (asymmetric) keys.

One way to do this could be to separate the retrieval of the key from the validation step. When you validate, you validate against a single JWK. The logic to retrieve that key could be simple, or not. I had to create a loop across a JWKS once for a customer as we did not have the kid inside the JWT header. If the retrieval of the key is part of the validation logic, I can't do that.

So something like:

  • Key retrieval (keyid, jwks | local JWK file) or my custom logic -> JWK Object
  • JWT validation (JWK, JWT)

@daneshk daneshk moved this from BackLog to Planned for Sprint in Ballerina Team Main Board Jan 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Planned for Sprint
Status: No status
Development

No branches or pull requests

4 participants