Code Monkey home page Code Monkey logo

Comments (5)

ycrumeyrolle avatar ycrumeyrolle commented on June 18, 2024

It depends of the cryptographic material at your disposal.
If you have a X509 certificate (X509Certificate2), the easiest way is to use the FromCertificate() method:
var key = RsaJwk.FromX509Certificate(certificate, withPrivateKey: true);

If you have the RSAParameters, use the method FromParameters
var key = RsaJwk.FromParameters(rsaParameters);

If you have the JSON representation in JWK format, use the FromJson method:
var key = RsaJwk.FromJson(jsonString);

Or if you have each component of the RSA key, call the constructor:
var key = new RsaJwk(d: { ... }, p: { ... }, q: { ... }, dp: { ... }, dq: { ... }, qi: { ... }, e: { ... }, n: { ... });
where each parameter is a byte[]

from jwt.

ycrumeyrolle avatar ycrumeyrolle commented on June 18, 2024

I fear that your RSA key is in PEM format, which is not supported in .Net until the a month ago dotnet/runtime#31201.

from jwt.

khandokar avatar khandokar commented on June 18, 2024

i used FromCertificate before creating the issue, google have .p12 file, but they are not recommending it, they are recommending the .json file but that was not in jwk format. The following keys exist in the file
{
"type": "",
"project_id": "",
"private_key_id": "",
"private_key": "",
"client_email": "",
"client_id": "",
"auth_uri": "",
"token_uri": "",
"auth_provider_x509_cert_url": "",
"client_x509_cert_url": ""
}
i know they are providing the ..cert_url from where i can download the JWK formed json file, But instead how can i use private_key(i attached private_key only)? is it possible to retrieve each component of RSA Key?

Thanks

from jwt.

ycrumeyrolle avatar ycrumeyrolle commented on June 18, 2024

The Google RSA private key is in PKCS8 format, ASN.1 structured.
The client_x509_cert_url provide certificates, but I did not had time to see what kind of key it contain.
This might be the public key as it is exposed on the Internet.

I started to write an ASN.1 parser #441
It will be something like:
RsaJwk.FromPkcs8PrivateKey("The private key");

from jwt.

khandokar avatar khandokar commented on June 18, 2024

That would be very nice.It will be available on next version right?

Thanks

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.