Fixed RS256, again

This commit is contained in:
Tracker-Friendly 2024-05-03 20:18:45 +01:00
parent 728279ec63
commit 04af6c00fb
1 changed files with 7 additions and 2 deletions

View File

@ -258,11 +258,17 @@ func main() {
log.Fatal("[ERROR] Failed to parse PEM block containing the private key") log.Fatal("[ERROR] Failed to parse PEM block containing the private key")
} }
privateKey, err = x509.ParsePKCS1PrivateKey(block.Bytes) privKey, err := x509.ParsePKCS8PrivateKey(block.Bytes)
if err != nil { if err != nil {
log.Fatal("[ERROR] Failed to parse private key:", err) log.Fatal("[ERROR] Failed to parse private key:", err)
} }
var ok bool
privateKey, ok = privKey.(*rsa.PrivateKey)
if !ok {
log.Fatal("[ERROR] Failed to convert private key to RSA private key")
}
pubKeyFile, err := os.ReadFile(PUBLIC_KEY_PATH) pubKeyFile, err := os.ReadFile(PUBLIC_KEY_PATH)
if err != nil { if err != nil {
log.Fatal("[ERROR] Cannot read public key:", err) log.Fatal("[ERROR] Cannot read public key:", err)
@ -278,7 +284,6 @@ func main() {
log.Fatal("[ERROR] Failed to parse public key:", err) log.Fatal("[ERROR] Failed to parse public key:", err)
} }
var ok bool
publicKey, ok = pubKey.(*rsa.PublicKey) publicKey, ok = pubKey.(*rsa.PublicKey)
if !ok { if !ok {
log.Fatal("[ERROR] Failed to convert public key to RSA public key") log.Fatal("[ERROR] Failed to convert public key to RSA public key")