iris/_examples/miscellaneous/jwt
Gerasimos (Makis) Maropoulos b2fddc7d68 jwt: add more helpers (DefaultRSA and DefaultHMAC)
Former-commit-id: fe06c0e0f4d7e121c678ffda7ac702ae865abd00
2020-05-31 17:57:30 +03:00
..
main.go jwt: add more helpers (DefaultRSA and DefaultHMAC) 2020-05-31 17:57:30 +03:00
README.md New builtin JWT middleware - this one supports encryption and ed25519 2020-05-27 12:02:17 +03:00
rsa_password_protected.key jwt: add more helpers (DefaultRSA and DefaultHMAC) 2020-05-31 17:57:30 +03:00

Generate RSA

$ openssl genrsa -des3 -out private_rsa.pem 2048
b, err := ioutil.ReadFile("./private_rsa.pem")
if err != nil {
    panic(err)
}
key := jwt.MustParseRSAPrivateKey(b, []byte("pass"))

OR

import "crypto/rand"
import "crypto/rsa"

key, err := rsa.GenerateKey(rand.Reader, 2048)

Generate Ed25519

$ openssl genpkey -algorithm Ed25519 -out private_ed25519.pem
$ openssl req -x509 -key private_ed25519.pem -out cert_ed25519.pem -days 365