From d06b49021adf253039b903caa83cad8d6f2a2c90 Mon Sep 17 00:00:00 2001 From: Johan Stenstam Date: Thu, 29 Aug 2024 12:56:17 +0200 Subject: [PATCH] * more work on name conversion TEM --> POP (or TAPIR-POP). --- apihandler.go | 16 ++++++++++++---- bootstrap.go | 2 +- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/apihandler.go b/apihandler.go index ba3c9bc..01a2397 100644 --- a/apihandler.go +++ b/apihandler.go @@ -484,7 +484,7 @@ func SetupRouter(conf *Config) *mux.Router { sr := r.PathPrefix("/api/v1").Headers("X-API-Key", viper.GetString("apiserver.key")).Subrouter() - sr.HandleFunc("/ping", tapir.APIping("tem", conf.BootTime)).Methods("POST") + sr.HandleFunc("/ping", tapir.APIping("tapir-pop", conf.BootTime)).Methods("POST") sr.HandleFunc("/command", APIcommand(conf)).Methods("POST") sr.HandleFunc("/bootstrap", APIbootstrap(conf)).Methods("POST") sr.HandleFunc("/debug", APIdebug(conf)).Methods("POST") @@ -497,7 +497,7 @@ func SetupBootstrapRouter(conf *Config) *mux.Router { r := mux.NewRouter().StrictSlash(true) sr := r.PathPrefix("/api/v1").Headers("X-API-Key", viper.GetString("apiserver.key")).Subrouter() - sr.HandleFunc("/ping", tapir.APIping("tem", conf.BootTime)).Methods("POST") + sr.HandleFunc("/ping", tapir.APIping("tapir-pop", conf.BootTime)).Methods("POST") sr.HandleFunc("/bootstrap", APIbootstrap(conf)).Methods("POST") // sr.HandleFunc("/debug", APIdebug(conf)).Methods("POST") // sr.HandleFunc("/show/api", tapir.APIshowAPI(r)).Methods("GET") @@ -533,8 +533,14 @@ func APIhandler(conf *Config, done <-chan struct{}) { addresses := viper.GetStringSlice("apiserver.addresses") tlsaddresses := viper.GetStringSlice("apiserver.tlsaddresses") - certfile := viper.GetString("certs.tem.cert") - keyfile := viper.GetString("certs.tem.key") + certfile := viper.GetString("certs.tapir-pop.cert") + if certfile == "" { + log.Printf("*** APIhandler: Error: TLS cert file not specified under key certs.tapir-pop.cert") + } + keyfile := viper.GetString("certs.tapir-pop.key") + if keyfile == "" { + log.Printf("*** APIhandler: Error: TLS key file not specified under key certs.tapir-pop.key") + } bootstrapaddresses := viper.GetStringSlice("bootstrapserver.addresses") bootstraptlsaddresses := viper.GetStringSlice("bootstrapserver.tlsaddresses") @@ -547,10 +553,12 @@ func APIhandler(conf *Config, done <-chan struct{}) { _, err := os.Stat(certfile) if os.IsNotExist(err) { + log.Printf("*** APIhandler: Error: TLS cert file \"%s\" does not exist", certfile) tlspossible = false } _, err = os.Stat(keyfile) if os.IsNotExist(err) { + log.Printf("*** APIhandler: Error: TLS key file \"%s\" does not exist", keyfile) tlspossible = false } diff --git a/bootstrap.go b/bootstrap.go index 2472a63..a92b4cd 100644 --- a/bootstrap.go +++ b/bootstrap.go @@ -29,7 +29,7 @@ func (td *TemData) BootstrapMqttSource(s *tapir.WBGlist, src SourceConf) (*tapir TEMExiter("BootstrapMqttSource error: missing config key: certs.certdir") } // cert := cd + "/" + certname - cert := cd + "/" + "tem" + cert := cd + "/" + "tapir-pop" tlsConfig, err := tapir.NewClientConfig(viper.GetString("certs.cacertfile"), cert+".key", cert+".crt") if err != nil { TEMExiter("BootstrapMqttSource: Error: Could not set up TLS: %v", err)