feat(config): add checks for Mii decryption key config

This commit is contained in:
Jemma Poffinbarger
2026-05-29 17:43:27 -05:00
parent 38aec18ae8
commit eacd16bc30

17
init.go
View File

@@ -1,6 +1,7 @@
package main
import (
"crypto/md5"
"crypto/rand"
"encoding/hex"
"fmt"
@@ -71,5 +72,21 @@ func init() {
"X-API-Key", globals.Config.AccountGRPCAPIKey,
)
if strings.TrimSpace(globals.Config.MiiDecryptKey) == "" {
globals.Logger.Warning("PN_FRIENDS_CONFIG_MII_DECRYPT_KEY environment variable not set. 3DS Mii data cannot be decrypted")
}
miiKeyBytes, err := hex.DecodeString(globals.Config.MiiDecryptKey)
if err != nil {
globals.Logger.Criticalf("Failed to decode PN_FRIENDS_CONFIG_MII_DECRYPT_KEY %v", err)
os.Exit(0)
}
miiMD5Hash := md5.Sum(miiKeyBytes)
if hex.EncodeToString(miiMD5Hash[:]) != "aeb707b225ec0fcd8a503e26e3dcd596" {
globals.Logger.Criticalf("PN_FRIENDS_CONFIG_MII_DECRYPT_KEY is incorrect! md5: %s", hex.EncodeToString(miiMD5Hash[:]))
os.Exit(0)
}
database.ConnectPostgres()
}