backend/enterprise/keys/README.md
These public keys are used to decrypt JWT license.
We can use openssl to generate RSA key
# Create private key
openssl genrsa -out private.pem 2048
# Use private key to generate public key
openssl rsa -in private.pem -outform PEM -pubout -out public.pem
The enterprise/config/config.go will load keys depends on environment.
In enterprise/service/license.go, we will use public key to parse JWT
token, err := jwt.Parse(tokenString, func(token *jwt.Token) (any, error) {
if _, ok := token.Method.(*jwt.SigningMethodRSA); !ok {
return nil, errors.Errorf("unexpected signing method: %v", token.Header["alg"])
}
key, err := jwt.ParseRSAPublicKeyFromPEM([]byte(env.Conf.LicensePubKey))
if err != nil {
return nil, err
}
return key
}