question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Sign JWT token using Azure Key Vault

See original GitHub issue

Hi. Apologies if it’s bad form to link straight to my StackOverflow question - I thought I’d save on the duplication. I’m happy to copy across the content if that’s preferred.

Basically, I’m having trouble signing a JWT via Azure Key Vault. It works fine if I don’t use Azure Key Vault. I put code example and full description in the Stackovlow question…

https://stackoverflow.com/questions/69117288/sign-jwt-token-using-azure-key-vault

Environment:

  • Name and version of the Library package used: Azure.Security.KeyVault.Keys 4.2.0
  • Hosting platform or OS and .NET runtime version (dotnet --info output for .NET Core projects): LINQPad 6 (which I believe is .NET 5 runtime)
  • IDE and version : LINQPad 6

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
heathscommented, Sep 10, 2021

Great!

FWIW, one thing I’ve learned over the years is that Windows-based APIs are often Unicode, i.e. wide chars, but industry standards more often tend to be UTF-8 based - JWTs and the family included. Encoding.UTF8 is technically correct in this case, but there’s the potential for more processing involved when, because the value is base64url-encoded, you know all the characters are ASCII already.

1reaction
dracancommented, Sep 10, 2021

@heaths - that’s amazing, it worked! 😃 It was literally just the changing from Encoding.Unicode. to Encoding.ASCII. that fixed it for me. Amazing how a single word can cause so many problems! The public keys that I pasted into jwt.io were all -----BEGIN CERTIFICATE-----, but I think that was fine. The tokens also weren’t working against the endpoint I was trying to authenticate against either - so it wasn’t just jwt.io. Using Encoding.ASCII, it all works perfectly! Thank you so much for your help with this 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Sign JWT token using Azure Key Vault
I'm using a private key to sign a JWT token, which works as expected. However, I'd like to leverage Azure Key Vault to...
Read more >
Get KeyVault certificate (or Keys) and Sign/Validate string
We have a sample policy snippet here which retrieve the secret from Azure Key Vault using named values and generate JWT token with...
Read more >
Azure Key Vault Secrets - BUILD A JWT AUTHENTICATION ...
Learn how to setup Azure Key Vault to manage secrets across several applications. Azure Key Vault is a great solution for centralizing a...
Read more >
Sign JWT token using Azure Key Vault - appsloveworld.com
I was able to get this to work and found that https://jwt.io is rather vague when it says you can paste either a...
Read more >
jwt-go signing methods backed by Azure Key Vault
jwt-go signing methods backed by Azure Key Vault. ... NewKey(client, kid) fail(err) // Generate a JWT token token := jwt.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found