GitBook: [master] one page modified

This commit is contained in:
CPol 2021-03-10 12:26:57 +00:00 committed by gitbook-bot
parent b3c8c325f1
commit c8225861c4
No known key found for this signature in database
GPG key ID: 07D2180C7B12D0FF

View file

@ -137,6 +137,18 @@ If the JWT has embedded a public key like in the following scenario:
![](../.gitbook/assets/image%20%28436%29.png)
Using the following nodejs script it's possible to generate a public key from that data:
```bash
const NodeRSA = require('node-rsa');
const fs = require('fs');
n ="ANQ3hoFoDxGQMhYOAc6CHmzz6_Z20hiP1Nvl1IN6phLwBj5gLei3e4e-DDmdwQ1zOueacCun0DkX1gMtTTX36jR8CnoBRBUTmNsQ7zaL3jIU4iXeYGuy7WPZ_TQEuAO1ogVQudn2zTXEiQeh-58tuPeTVpKmqZdS3Mpum3l72GHBbqggo_1h3cyvW4j3QM49YbV35aHV3WbwZJXPzWcDoEnCM4EwnqJiKeSpxvaClxQ5nQo3h2WdnV03C5WuLWaBNhDfC_HItdcaZ3pjImAjo4jkkej6mW3eXqtmDX39uZUyvwBzreMWh6uOu9W0DMdGBbfNNWcaR5tSZEGGj2divE8";
e = "AQAB";
const key = new NodeRSA();
var importedKey = key.importKey({n: Buffer.from(n, 'base64'),e: Buffer.from(e, 'base64'),}, 'components-public');
console.log(importedKey.exportKey("public"));
```
It's possible to generate a new private/public key, embeded the new public key inside the token and use it to generate a new signature:
```bash