Giter Club home page Giter Club logo

Comments (8)

proggeramlug avatar proggeramlug commented on May 27, 2024 1

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.

calebkleveter avatar calebkleveter commented on May 27, 2024 1

@dev4jam

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.

dev4jam avatar dev4jam commented on May 27, 2024

PEM

from usermanager.

proggeramlug avatar proggeramlug commented on May 27, 2024

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.

dev4jam avatar dev4jam commented on May 27, 2024

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.

dev4jam avatar dev4jam commented on May 27, 2024

is that exactly what I need to set in the configuration?

from usermanager.

proggeramlug avatar proggeramlug commented on May 27, 2024

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.

dev4jam avatar dev4jam commented on May 27, 2024

sure 😂

from usermanager.

Related Issues (18)

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.