mirror of
https://codeberg.org/Codeberg/pages-server.git
synced 2025-04-25 06:16:58 +00:00
fix integration test
This commit is contained in:
parent
f79d7501a4
commit
2238a57801
4 changed files with 18 additions and 6 deletions
|
@ -21,15 +21,21 @@ func setupAcmeConfig(cfg config.ACMEConfig) (*lego.Config, error) {
|
|||
var myAcmeAccount AcmeAccount
|
||||
var myAcmeConfig *lego.Config
|
||||
|
||||
if cfg.AccountConfigFile == "" {
|
||||
return nil, fmt.Errorf("invalid acme config file: '%s'", cfg.AccountConfigFile)
|
||||
}
|
||||
|
||||
if account, err := os.ReadFile(cfg.AccountConfigFile); err == nil {
|
||||
log.Info().Msgf("found existing acme account config file '%s'", cfg.AccountConfigFile)
|
||||
if err := json.Unmarshal(account, &myAcmeAccount); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
myAcmeAccount.Key, err = certcrypto.ParsePEMPrivateKey([]byte(myAcmeAccount.KeyPEM))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
myAcmeConfig = lego.NewConfig(&myAcmeAccount)
|
||||
myAcmeConfig.CADirURL = cfg.APIEndpoint
|
||||
myAcmeConfig.Certificate.KeyType = certcrypto.RSA2048
|
||||
|
@ -40,6 +46,7 @@ func setupAcmeConfig(cfg config.ACMEConfig) (*lego.Config, error) {
|
|||
log.Info().Err(err).Msg("config validation failed, you might just delete the config file and let it recreate")
|
||||
return nil, fmt.Errorf("acme config validation failed: %w", err)
|
||||
}
|
||||
|
||||
return myAcmeConfig, nil
|
||||
} else if !os.IsNotExist(err) {
|
||||
return nil, err
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue