Comments (5)
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.
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.
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.
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.
That would be very nice.It will be available on next version right?
Thanks
from jwt.
Related Issues (20)
- Use an `IBufferWriter` when decompressing a JWT HOT 1
- Extract JWK logic into a separate assembly
- Extract cryptography logic into a separate assembly
- Signature validation fails when no signature algorithm is specified HOT 4
- Operation is not supported on this platform. HOT 8
- AES-GCM key wrapping is generating a nonce with low entropy
- Adds support for encrypted JWK
- Adds a CLI HOT 1
- MacOS build fail
- Adding already existing member to JsonObject creates a duplicate
- JwsDescriptor.Payload setter weird behavior. HOT 7
- Typo in the AlgorithmId.ES256X? HOT 4
- What is the meaning of 'defaultAlgorithm'? HOT 1
- JWKS ToString broken on 1.9.1 HOT 2
- Manual refresh for JwksHttpKeyProvider HOT 2
- Read SignatureAlgorithm from X509Certificate if available HOT 14
- https://jwt.io/#debugger-io?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.3ZlNebfhKEZ_HqKPIZFoI6Ro_YBlS7z2Oct4zfleOIk HOT 1
- Encrypted key present in ECDH-ES algorithm results in Invalid JWE HOT 9
- Hash-Algorithm for key derivation (ECDH-ES) HOT 2
- ECJwk GetCanonicalizeSize wrong - Kid randomly wrong HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jwt.