update go mod, remove tls insecure skip verifies

This commit is contained in:
2026-05-28 20:02:54 +00:00
parent c177f7d45b
commit b0bcaf61a2
6 changed files with 33 additions and 24 deletions
+14 -5
View File
@@ -2,6 +2,7 @@ package app
import (
"encoding/json"
"log"
"os"
)
@@ -34,15 +35,23 @@ type Config struct {
PVE PVEConfig `json:"pve"`
}
func GetConfig(configPath string) (Config, error) {
content, err := os.ReadFile(configPath)
func GetConfig(configPath string) Config {
root, err := os.OpenRoot(".")
if err != nil {
return Config{}, err
log.Fatal("Error when opening root dir: ", err)
}
defer root.Close()
content, err := root.ReadFile(configPath)
if err != nil {
log.Fatal("Error when opening config file: ", err)
}
var config Config
err = json.Unmarshal(content, &config)
if err != nil {
return Config{}, err
log.Fatal("Error during parsing config file: ", err)
}
return config, nil
return config
}
+1 -1
View File
@@ -25,7 +25,7 @@ func NewClientFromCredentials(config common.LDAPConfig, username common.Username
}
if config.StartTLS {
err = LDAPConn.StartTLS(&tls.Config{InsecureSkipVerify: true})
err = LDAPConn.StartTLS(&tls.Config{})
if err != nil {
return nil, http.StatusInternalServerError, err
}
+10 -4
View File
@@ -14,14 +14,20 @@ type DB struct {
func LoadDB(localDBPath string) (DB, error) {
db := DB{}
content, err := os.ReadFile(localDBPath)
root, err := os.OpenRoot(".")
if err != nil {
//log.Fatal("Error when opening file: ", err)
return db, err
}
defer root.Close()
content, err := root.ReadFile(localDBPath)
if err != nil {
return db, err
}
err = json.Unmarshal(content, &db.data)
if err != nil {
//log.Fatal("Error during Unmarshal(): ", err)
return db, err
}
return db, nil
@@ -32,7 +38,7 @@ func SaveDB(localDBPath string, db DB) error {
if err != nil {
return err
}
err = os.WriteFile(localDBPath, []byte(json), 0644)
err = os.WriteFile(localDBPath, []byte(json), 0600)
return err
}
+3 -7
View File
@@ -30,10 +30,8 @@ var Realms map[string]Realm
func Run(configPath *string, localDBPath *string) {
// load config values
var err error
Config, err = common.GetConfig(*configPath)
if err != nil {
log.Fatalf("Error when reading config file: %s\n", err)
}
Config = common.GetConfig(*configPath)
// already exits if failed
log.Printf("Read in config from %s\n", *configPath)
// load localdb
@@ -551,9 +549,7 @@ func GetRealmsFromPVE(config *common.Config) map[string]Realm {
HTTPClient := http.Client{
Transport: &http.Transport{
TLSClientConfig: &tls.Config{
InsecureSkipVerify: true,
},
TLSClientConfig: &tls.Config{},
},
}
token := fmt.Sprintf(`%s@%s!%s`, config.PVE.Token.User, config.PVE.Token.Realm, config.PVE.Token.ID)
+1 -3
View File
@@ -21,9 +21,7 @@ type ProxmoxClient struct {
func NewClientFromCredentials(config common.PVEConfig, username common.Username, password string) (*ProxmoxClient, int, error) {
HTTPClient := http.Client{
Transport: &http.Transport{
TLSClientConfig: &tls.Config{
InsecureSkipVerify: true,
},
TLSClientConfig: &tls.Config{},
},
}