feat: add key EC and loading file key
parent
0011b99bb8
commit
461047e61c
|
@ -0,0 +1,5 @@
|
|||
-----BEGIN EC PRIVATE KEY-----
|
||||
MHcCAQEEIMBU9Lpa2n8mRZRYcwUQIocClAcqUJ6hoaELjzU6oKchoAoGCCqGSM49
|
||||
AwEHoUQDQgAEurZ50Sl3XxMjTnK64gl0YEWSSc92LUMnN7aR8NRksnNnI7TpPhvC
|
||||
wCGOMK8uiuEECpAxR+5lSkcbIBuDICaJXg==
|
||||
-----END EC PRIVATE KEY-----
|
|
@ -0,0 +1,4 @@
|
|||
-----BEGIN PUBLIC KEY-----
|
||||
MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEurZ50Sl3XxMjTnK64gl0YEWSSc92
|
||||
LUMnN7aR8NRksnNnI7TpPhvCwCGOMK8uiuEECpAxR+5lSkcbIBuDICaJXg==
|
||||
-----END PUBLIC KEY-----
|
|
@ -0,0 +1,9 @@
|
|||
#!/bin/bash
|
||||
|
||||
# access
|
||||
openssl ecparam -outform PEM -genkey -name prime256v1 -noout -out access.private.pem
|
||||
openssl ec -inform PEM -outform PEM -in access.private.pem -pubout -out access.public.pem
|
||||
|
||||
# refresh
|
||||
openssl ecparam -outform PEM -genkey -name secp384r1 -noout -out refresh.private.pem
|
||||
openssl ec -inform PEM -outform PEM -in refresh.private.pem -pubout -out refresh.public.pem
|
|
@ -0,0 +1,6 @@
|
|||
-----BEGIN EC PRIVATE KEY-----
|
||||
MIGkAgEBBDAXXrLP/3gmmNUGlrFkrlGAthIAgoGWpQ915fzA/6JOe45meJBva2C7
|
||||
XXwRNrDevEKgBwYFK4EEACKhZANiAAQ2ucELV0yFhvUygj73BOtbHrBI4pKdp7pJ
|
||||
V6QSJ27xqdjdlhCCOUcntoRcRwk6XW/Q2Tf9fg+wrDOVIlQFmJkoah1DAVmgThZQ
|
||||
gOx5VDlWFaxPm3CdPgkhbpbrC6qr0yE=
|
||||
-----END EC PRIVATE KEY-----
|
|
@ -0,0 +1,5 @@
|
|||
-----BEGIN PUBLIC KEY-----
|
||||
MHYwEAYHKoZIzj0CAQYFK4EEACIDYgAENrnBC1dMhYb1MoI+9wTrWx6wSOKSnae6
|
||||
SVekEidu8anY3ZYQgjlHJ7aEXEcJOl1v0Nk3/X4PsKwzlSJUBZiZKGodQwFZoE4W
|
||||
UIDseVQ5VhWsT5twnT4JIW6W6wuqq9Mh
|
||||
-----END PUBLIC KEY-----
|
|
@ -0,0 +1,37 @@
|
|||
/**
|
||||
* Created by fbonhomm
|
||||
* Email: flo-github@outlook.fr
|
||||
* Licence: MIT
|
||||
*/
|
||||
|
||||
package services
|
||||
|
||||
import (
|
||||
"crypto/ecdsa"
|
||||
"github.com/dgrijalva/jwt-go"
|
||||
"io/ioutil"
|
||||
)
|
||||
|
||||
const ROOT = "./source/services"
|
||||
|
||||
var PublicKeyAccess *ecdsa.PublicKey
|
||||
var PrivateKeyAccess *ecdsa.PrivateKey
|
||||
var PublicKeyRefresh *ecdsa.PublicKey
|
||||
var PrivateKeyRefresh *ecdsa.PrivateKey
|
||||
var err error
|
||||
|
||||
func init() {
|
||||
var tmp []byte
|
||||
|
||||
tmp, _ = ioutil.ReadFile(ROOT + "/jwt/access.public.pem")
|
||||
PublicKeyAccess, _ = jwt.ParseECPublicKeyFromPEM(tmp)
|
||||
|
||||
tmp, _ = ioutil.ReadFile(ROOT + "/jwt/access.private.pem")
|
||||
PrivateKeyAccess, _ = jwt.ParseECPrivateKeyFromPEM(tmp)
|
||||
|
||||
tmp, _ = ioutil.ReadFile(ROOT + "/jwt/refresh.public.pem")
|
||||
PublicKeyRefresh, _ = jwt.ParseECPublicKeyFromPEM(tmp)
|
||||
|
||||
tmp, _ = ioutil.ReadFile(ROOT + "/jwt/refresh.private.pem")
|
||||
PrivateKeyRefresh, _ = jwt.ParseECPrivateKeyFromPEM(tmp)
|
||||
}
|
Loading…
Reference in New Issue