xxxxxxxxxx
keyBytes, err := os.ReadFile("private.pem")
if err != nil {
fmt.Println("Error reading the key file:", err)
os.Exit(1)
}
// Decode the PEM block from the key file
block, _ := pem.Decode(keyBytes)
if block == nil || block.Type != "PRIVATE KEY" {
fmt.Println("Failed to decode PEM block containing private key")
os.Exit(1)
}
// Parse the private key
key, err := x509.ParsePKCS8PrivateKey(block.Bytes)
if err != nil {
fmt.Println("Error parsing private key:", err)
os.Exit(1)
}