From 9d46e852e7407de812675d2dbadc0664b4bf2c32 Mon Sep 17 00:00:00 2001 From: petricadaipegsp <155911522+petricadaipegsp@users.noreply.github.com> Date: Thu, 31 Oct 2024 18:59:41 +0100 Subject: [PATCH] Support QUILIBRIUM_SIGNATURE_CHECK in client (#314) --- client/cmd/root.go | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/client/cmd/root.go b/client/cmd/root.go index 5b8b5e5..b8db6a2 100644 --- a/client/cmd/root.go +++ b/client/cmd/root.go @@ -6,6 +6,7 @@ import ( "encoding/hex" "fmt" "os" + "strconv" "strings" "github.com/cloudflare/circl/sign/ed448" @@ -150,6 +151,20 @@ func GetGRPCClient() (*grpc.ClientConn, error) { ) } +func signatureCheckDefault() bool { + envVarValue, envVarExists := os.LookupEnv("QUILIBRIUM_SIGNATURE_CHECK") + if envVarExists { + def, err := strconv.ParseBool(envVarValue) + if err == nil { + return def + } else { + fmt.Println("Invalid environment variable QUILIBRIUM_SIGNATURE_CHECK, must be 'true' or 'false'. Got: " + envVarValue) + } + } + + return true +} + func init() { rootCmd.PersistentFlags().StringVar( &configDirectory, @@ -166,7 +181,7 @@ func init() { rootCmd.PersistentFlags().BoolVar( &signatureCheck, "signature-check", - true, - "bypass signature check (not recommended for binaries)", + signatureCheckDefault(), + "bypass signature check (not recommended for binaries) (default true or value of QUILIBRIUM_SIGNATURE_CHECK env var)", ) }