diff --git a/README.md b/README.md index 97a097d8..6332b6df 100644 --- a/README.md +++ b/README.md @@ -127,9 +127,10 @@ The `sqlcmd` project aims to be a complete port of the original ODBC sqlcmd to t The following switches have different behavior in this version of `sqlcmd` compared to the original ODBC based `sqlcmd`. - `-R` switch is ignored. The go runtime does not provide access to user locale information, and it's not readily available through syscall on all supported platforms. - `-I` switch is ignored; quoted identifiers are always set on. To disable quoted identifier behavior, add `SET QUOTED IDENTIFIER OFF` in your scripts. -- `-N` now takes a string value that can be one of `true`, `false`, or `disable` to specify the encryption choice. +- `-N` now takes a string value that can be one of `strict`,`true`,`mandatory`,`yes`,`1`,`t`, `optional`, `no`, `0`, `f`, `false`, or `disable` to specify the encryption choice. - If `-N` and `-C` are not provided, sqlcmd will negotiate authentication with the server without validating the server certificate. - If `-N` is provided but `-C` is not, sqlcmd will require validation of the server certificate. Note that a `false` value for encryption could still lead to encryption of the login packet. + - `-C` has no effect when `strict` value is specified for `-N`. - If both `-N` and `-C` are provided, sqlcmd will use their values for encryption negotiation. - More information about client/server encryption negotiation can be found at - `-u` The generated Unicode output file will have the UTF16 Little-Endian Byte-order mark (BOM) written to it. diff --git a/cmd/sqlcmd/sqlcmd.go b/cmd/sqlcmd/sqlcmd.go index 064312b8..c77f96c3 100644 --- a/cmd/sqlcmd/sqlcmd.go +++ b/cmd/sqlcmd/sqlcmd.go @@ -455,10 +455,10 @@ func normalizeFlags(cmd *cobra.Command) error { case encryptConnection: value := strings.ToLower(v) switch value { - case "false", "true", "disable": + case "mandatory", "yes", "1", "t", "true", "disable", "optional", "no", "0", "f", "false", "strict": return pflag.NormalizedName(name) default: - err = invalidParameterError("-N", v, "false", "true", "disable") + err = invalidParameterError("-N", v, "mandatory", "yes", "1", "t", "true", "disable", "optional", "no", "0", "f", "false", "strict") return pflag.NormalizedName("") } case format: diff --git a/cmd/sqlcmd/sqlcmd_test.go b/cmd/sqlcmd/sqlcmd_test.go index 057926ac..2ab695c1 100644 --- a/cmd/sqlcmd/sqlcmd_test.go +++ b/cmd/sqlcmd/sqlcmd_test.go @@ -150,6 +150,7 @@ func TestInvalidCommandLine(t *testing.T) { {[]string{"-P"}, "'-P': Missing argument. Enter '-?' for help."}, {[]string{"-;"}, "';': Unknown Option. Enter '-?' for help."}, {[]string{"-t", "-2"}, "'-t -2': value must be greater than or equal to 0 and less than or equal to 65534."}, + {[]string{"-N", "invalid"}, "'-N invalid': Unexpected argument. Argument value has to be one of [mandatory yes 1 t true disable optional no 0 f false strict]."}, } for _, test := range commands {