Comments (8)
You can read all about it here: https://tools.ietf.org/html/rfc7517
What it essentially means is that N is the modulus component of your RSA key and D is your private exponent. The names aren't picked very well, but that's what it is. ;)
This is an interesting issue however, since the creation/conversion from one project to another should be rather smooth. What format is your private key in?
from usermanager.
First, I want to note that because certificates only contain public keys, you can only read and verify signed JWTs with them, not sign them.
But for using a PEM cert, I just made an update to one of the dependencies for this project (JWTVapor), so if you update your packages (swift package update
or vapor update -y
) the should be a class CertService
exported from it. If you go into your global configure
function, you can change the JWTProvider
closure to something like this:
let jwtProvider = JWTProvider { cert in
let headers = JWTHeader(alg: "RS256", crit: ["exp", "aud"], kid: "user_manager_kid")
return try CertService(certificate: cert, header: headers)
}
The JWT_SECRET
environment variable should then be set to the PEM certificate you are using. Another option would be to create an empty environment variable (the provider expects one and will throw an error if one doesn't exist) and then read the cert from disk using FileManager
.
from usermanager.
PEM
from usermanager.
Can you do me a favor? Try this little bash-script with your key-file and see if that works:
#!/bin/bash
data=$(openssl rsa -in my-key.key -noout -modulus)
length=${#data}
modulus=${data:8:length}
modulusMd5="test"
echo "N:"
echo $modulus | xxd -r -p | base64
data=$(openssl rsa -in dummy.key -noout -text)
p1=$(echo $data | python -c 'print(raw_input().index("privateExponent: "))+17')
p2=$(echo $data | python -c 'print(raw_input().index("prime1:"))')
d=$((p2-p1))
p=$(echo $data)
echo "D:"
echo ${p:p1:d} | xxd -r -p | base64
make sure to adjust "my-key.key" to match your file
from usermanager.
It printed out:
N:
6vIAUNUo3xGPvlzP+1KxxWQ8rSmJiqAuyDJJbYqlOeqOjIVQNAC8CdKv2hisGnUTxFw+tY0Dm0girCSgePC4ma2t7USzqcoStgNUAvPXBtEY1jiPl83XByZP8qE4FSEcFvP9rLyHWiw+haRKijQl0JJnrnjaU0G4BNepWUVyNPcSVrPKo5PT297OGOjMaolIEUTF0I2pPelY1hCGus7t2stm4Qa2swAZAj6kq6QPgJzrtTYKPSfAUDSP0HCHedBXZBfxDQ7OGuxjv0WRN2O/5wJnBzGayu2DdB2JPotcMzVSi1ThyKx1ACYkbLF2ViWFSkwZNeEZzCiNsmg83narkw==
D:
NAGrtjjpGi+9/Op4k25jsYkVsVMPgiMhF+mhvWDCYEaelVZxQYGkHhyIFqP9fMHLxVyR+Qgk8zuNiUN2Ti8i/cmnRW0+w+faKnYkI58sSvMAJ3NPvc+vuIJvkgrD6lFw8VfDIHh/EaPXlyed5GfUsw2la8aOtX1HqbK/ZuZreHOIBMqP94chN9sA6Gyuv663mzhKoWJlCQGito7cCNtwYuR/mdLV2vLQsX+PENM5qO8InCJCflEjuZgP37jeb1jTiWYdPNW+3oMwo/Us5Tjn3DrYye5jefKiF+wbzapSs2nlnCL+mrA6VG1ZZ0CZ3b+V+8s++vvo3pYqDosFyb4XMQ==
from usermanager.
is that exactly what I need to set in the configuration?
from usermanager.
Those should be the values you need, yes.
Note: Since they are now public in GitHub I hope this is not some kind of production environment. :)
from usermanager.
sure 😂
from usermanager.
Related Issues (18)
- Update Documentation for Vapor 3
- Make User registraion public/private HOT 2
- Suggestion: Add third-party oauth methods HOT 12
- Not clear how register (and login) works HOT 8
- GPDR Routes
- Database Credentials should be environment variables HOT 1
- error: swift build
- PEM_read_bio_PrivateKey - Unexpectedly found nil while unwrapping an Optional value HOT 2
- Build Error
- Swift Tools HOT 4
- Run production-tests
- Dockerfile adjustments HOT 1
- Errors are not very informative
- Email-code in API response
- Sendgrid integration not quite functional
- Allow other services to integrate HOT 2
- Admin-Functions
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 usermanager.