// Reload reloads the configuration of the CA and calls to the server Reload
// method.
Reload reloads the configuration of the CA and calls to the server Reload
method.
// Reload reloads the configuration of the CA and calls to the server Reload // method .
func (ca *CA) Reload() error {
	config, err := authority.LoadConfiguration(ca.opts.configFile)
	if err != nil {
		return errors.Wrap(err, "error reloading ca configuration")
	}
	logContinue := func(reason string) {
		log.Println(reason)
		log.Println("Continuing to run with the original configuration.")
		log.Println("You can force a restart by sending a SIGTERM signal and then restarting the step-ca.")
	}
	if !reflect.DeepEqual(ca.config.DB, config.DB) {
		logContinue("Reload failed because the database configuration has changed.")
		return errors.New("error reloading ca: database configuration cannot change")
	}
	newCA, err := New(config,
		WithPassword(ca.opts.password),
		WithIssuerPassword(ca.opts.issuerPassword),
		WithConfigFile(ca.opts.configFile),
		WithDatabase(ca.auth.GetDatabase()),
	)
	if err != nil {
		logContinue("Reload failed because the CA with new configuration could not be initialized.")
		return errors.Wrap(err, "error reloading ca")
	}
	if ca.insecureSrv != nil {
		if err = ca.insecureSrv.Reload(newCA.insecureSrv); err != nil {
			logContinue("Reload failed because insecure server could not be replaced.")
			return errors.Wrap(err, "error reloading insecure server")
		}
	}
	if err = ca.srv.Reload(newCA.srv); err != nil {
		logContinue("Reload failed because server could not be replaced.")
		return errors.Wrap(err, "error reloading server")
	}
	ca.renewer.Stop()
	ca.auth.CloseForReload()
	ca.auth = newCA.auth
	ca.config = newCA.config
	ca.opts = newCA.opts
	ca.renewer = newCA.renewer
	return nil
}
func ( ca * CA ) Reload ( ) error { config , err := authority . LoadConfiguration ( ca . opts . configFile ) if err != nil { return errors . Wrap ( err , " " ) } logContinue := func ( reason string ) { log . Println ( reason ) log . Println ( " " ) log . Println ( " " ) } if ! reflect . DeepEqual ( ca . config . DB , config . DB ) { logContinue ( " " ) return errors . New ( " " ) } newCA , err := New ( config , WithPassword ( ca . opts . password ) , WithIssuerPassword ( ca . opts . issuerPassword ) , WithConfigFile ( ca . opts . configFile ) , WithDatabase ( ca . auth . GetDatabase ( ) ) , ) if err != nil { logContinue ( " " ) return errors . Wrap ( err , " " ) } if ca . insecureSrv != nil { if err = ca . insecureSrv . Reload ( newCA . insecureSrv ) ; err != nil { logContinue ( " " ) return errors . Wrap ( err , " " ) } } if err = ca . srv . Reload ( newCA . srv ) ; err != nil { logContinue ( " " ) return errors . Wrap ( err , " " ) } ca . renewer . Stop ( ) ca . auth . CloseForReload ( ) ca . auth = newCA . auth ca . config = newCA . config ca . opts = newCA . opts ca . renewer = newCA . renewer return nil }
Reload reloads the configuration of the CA and calls to the server Reload
method.
Reload reloads the configuration of the CA and calls to the server Reload method .
// Do not allow reload if the database configuration has changed. // 1. Stop previous renewer // 2. Safely shutdown any internal resources (e.g. key manager) // 3. Replace ca properties // Do not replace ca.srv