Skip to content

Commit

Permalink
Lisätttiin private keyn tyypin mukainen dekoodaus
Browse files Browse the repository at this point in the history
  • Loading branch information
Mika Salminen committed Jan 6, 2025
1 parent 4a3e869 commit eef24dd
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,17 @@ func ValidateCertificate(certPEM, keyPEM string) error {
return errors.New("failed to parse private key PEM")
}

privateKey, err := x509.ParsePKCS8PrivateKey(keyBlock.Bytes)
var privateKey interface{}
switch keyBlock.Type {
case "RSA PRIVATE KEY":
privateKey, err = x509.ParsePKCS1PrivateKey(keyBlock.Bytes)
case "EC PRIVATE KEY":
privateKey, err = x509.ParseECPrivateKey(keyBlock.Bytes)
case "PRIVATE KEY":
privateKey, err = x509.ParsePKCS8PrivateKey(keyBlock.Bytes)
default:
return errors.New("unsupported private key type")
}
if err != nil {
return fmt.Errorf("failed to parse private key: %v", err)
}
Expand Down Expand Up @@ -95,7 +105,7 @@ func ValidateCertificate(certPEM, keyPEM string) error {

type PatroniConfig struct {
Etcd3 struct {
CAFile string `yaml:"ca"`
CAFile string `yaml:"cacert"`
CertFile string `yaml:"cert"`
KeyFile string `yaml:"key"`
URL string `yaml:"url"`
Expand Down

0 comments on commit eef24dd

Please sign in to comment.