mirror of
https://github.com/1f349/orchid.git
synced 2024-12-22 08:04:10 +00:00
Decode certificate private key from pem encoding
This commit is contained in:
parent
2989a1e749
commit
5322d4b096
@ -392,11 +392,15 @@ func (s *Service) getDnsProvider(name, token string) (challenge.Provider, error)
|
|||||||
|
|
||||||
// getPrivateKey reads the private key for the specified certificate id
|
// getPrivateKey reads the private key for the specified certificate id
|
||||||
func (s *Service) getPrivateKey(id uint64) (*rsa.PrivateKey, error) {
|
func (s *Service) getPrivateKey(id uint64) (*rsa.PrivateKey, error) {
|
||||||
privKeyBytes, err := os.ReadFile(filepath.Join(s.keyDir, fmt.Sprintf("%d.key.pem", id)))
|
pemBytes, err := os.ReadFile(filepath.Join(s.keyDir, fmt.Sprintf("%d.key.pem", id)))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return x509.ParsePKCS1PrivateKey(privKeyBytes)
|
keyBlock, _ := pem.Decode(pemBytes)
|
||||||
|
if keyBlock.Type != "RSA PRIVATE KEY" {
|
||||||
|
return nil, fmt.Errorf("invalid pem block type")
|
||||||
|
}
|
||||||
|
return x509.ParsePKCS1PrivateKey(keyBlock.Bytes)
|
||||||
}
|
}
|
||||||
|
|
||||||
// renewCert sets the renewing state in the database, calls renewCertInternal,
|
// renewCert sets the renewing state in the database, calls renewCertInternal,
|
||||||
|
Loading…
Reference in New Issue
Block a user