Support QUILIBRIUM_SIGNATURE_CHECK in client (#314)

This commit is contained in:
petricadaipegsp 2024-10-31 18:59:41 +01:00 committed by GitHub
parent dca4649281
commit 9d46e852e7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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)",
)
}