Adds tls command line parameters validation

This commit is contained in:
Mitja Živković
2020-11-16 09:19:29 +01:00
parent 1acc37af60
commit 0c3a3e69d9

View File

@@ -83,6 +83,14 @@ func main() {
log.Fatalf("Invalid arguments: messages count should be > 1, given: %v", *count) log.Fatalf("Invalid arguments: messages count should be > 1, given: %v", *count)
} }
if *cert != "" && *key == "" {
log.Fatal("Invalid arguments: private key path missing")
}
if *cert == "" && *key != "" {
log.Fatalf("Invalid arguments: certificate path missing")
}
var tlsConfig *tls.Config var tlsConfig *tls.Config
if *cert != "" && *key != "" { if *cert != "" && *key != "" {
tlsConfig = generateTlsConfig(*cert, *key) tlsConfig = generateTlsConfig(*cert, *key)