Code Monkey home page Code Monkey logo

Comments (11)

abatishchev avatar abatishchev commented on May 8, 2024

Google uses RS256 to encode JWT which is supported only in this branch: https://github.com/abatishchev/jwt/tree/rs256-1

from jwt.

simoneisner avatar simoneisner commented on May 8, 2024

Hi Alexander... Sorry for the delay and thanks for the reply. I downloaded the branch and I'm getting the same issue. I'm assuming I should be using the Google secret to decode the token. Is there a better forum for posting these types of questions on this library?

from jwt.

xnog avatar xnog commented on May 8, 2024

Alexander, can you please provide an example? I am getting error caling:

byte[] key = File.ReadAllBytes("C:\key.pub");
String secret = "xxxxxx";
string jsonPayload = JWT.JsonWebToken.Encode(payload, key, secret, JWT.JwtHashAlgorithm.RS256);


private static byte[] RS256(byte[] key, string secret, byte[] value)
{
var cert = new X509Certificate2(key, secret); <<<<<<<<<<<<<<<<<<<<

"An unhandled exception of type 'System.Security.Cryptography.CryptographicException' occurred in mscorlib.dll

Additional information: O objeto necessário não foi encontrado."

from jwt.

abatishchev avatar abatishchev commented on May 8, 2024

I'm sorry, missed your previous comment.

Are you sure you want to import a pub file not a pfx file? Pub contains the secret, doesn't it? Which usually goes as the second string paramter in plain string.

from jwt.

xnog avatar xnog commented on May 8, 2024

I was looking in JWT website (http://jwt.io/#debugger) and thought that the "key" parameter was the public or private key, but now I know that should be a pfx file. I create and now It worked, but I had to made some changes in the code.

  • In the method GetHashAlgorithm [ private static JwtHashAlgorithm GetHashAlgorithm(string algorithm) ] I had to add the "RS256" case. [ case "RS256": return JwtHashAlgorithm.RS256; ]
  • The Decode method doesn't have the 'secret' parameter, I override it.

Thanks.

from jwt.

simoneisner avatar simoneisner commented on May 8, 2024

Hi Alexander/xnog…

When I set up my Google+ account, they provided me with a secret. Shouldn’t this secret be used for signature verification?

From: xnog [mailto:[email protected]]
Sent: June 26, 2015 8:38 AM
To: jwt-dotnet/jwt
Cc: Simon Eisner
Subject: Re: [jwt] Trying to verify token does not work (#27)

I was looking in JWT website (http://jwt.io/#debugger) and thought that the "key" parameter was the public or private key, but now I know that should be a pfx file. I create and now It worked, but I have to made some changes in the code.

1 - In the method GetHashAlgorithm [ private static JwtHashAlgorithm GetHashAlgorithm(string algorithm) ] I had to add the "RS256" case. [ case "RS256": return JwtHashAlgorithm.RS256; ]

2 - The Decode method doesn't have the 'secret' parameter, I override it.

Thanks.
https://github.com/xnog


Reply to this email directly or view it on GitHubhttps://github.com//issues/27#issuecomment-115664430.

from jwt.

abatishchev avatar abatishchev commented on May 8, 2024

Google+? Or do you mean Google+ API?

I think they assign keys at Dev Console.

from jwt.

simoneisner avatar simoneisner commented on May 8, 2024

That’s where I got the client and secret… at the Dev Console. I’m not sure what a certificate pfx or pub file would have to do with this? Do I just need to create a text file, and add the secret into there? That’s what I’m not following. I thought the secret from the Dev Console would be used to sign the tokens.

[cid:[email protected]]

From: Alexander Batishchev [mailto:[email protected]]
Sent: June 26, 2015 12:29 PM
To: jwt-dotnet/jwt
Cc: Simon Eisner
Subject: Re: [jwt] Trying to verify token does not work (#27)

Google+? Or do you mean Google+ API?

I think they assign keys at Dev Consolehttps://code.google.com/apis/console/.


Reply to this email directly or view it on GitHubhttps://github.com//issues/27#issuecomment-115746929.

from jwt.

abatishchev avatar abatishchev commented on May 8, 2024

You may want to convert your pfx into base64 string and keep it in Web.config for instance:

Next time you need it you construct X509Certificate2 using its base64 representation and the secret:

var cert = new X509Certificate2(Convert.FromBase64String(key), secret);

from jwt.

abatishchev avatar abatishchev commented on May 8, 2024

Hey, how is going? Did you it get it working?

from jwt.

simoneisner avatar simoneisner commented on May 8, 2024

Hey there... no not yet. I haven't had a chance to try the converstion the way you're saying. I'm guessing I would use our domain PFX. I will try that today. Thanks for checking back.

from jwt.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.