Skip to content

Commit 2c2da58

Browse files
Add -N strict option (#459)
Co-authored-by: David Shiflet <[email protected]>
1 parent 45cd020 commit 2c2da58

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,10 @@ The `sqlcmd` project aims to be a complete port of the original ODBC sqlcmd to t
127127
The following switches have different behavior in this version of `sqlcmd` compared to the original ODBC based `sqlcmd`.
128128
- `-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.
129129
- `-I` switch is ignored; quoted identifiers are always set on. To disable quoted identifier behavior, add `SET QUOTED IDENTIFIER OFF` in your scripts.
130-
- `-N` now takes a string value that can be one of `true`, `false`, or `disable` to specify the encryption choice.
130+
- `-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.
131131
- If `-N` and `-C` are not provided, sqlcmd will negotiate authentication with the server without validating the server certificate.
132132
- 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.
133+
- `-C` has no effect when `strict` value is specified for `-N`.
133134
- If both `-N` and `-C` are provided, sqlcmd will use their values for encryption negotiation.
134135
- More information about client/server encryption negotiation can be found at <https://docs.microsoft.com/openspecs/windows_protocols/ms-tds/60f56408-0188-4cd5-8b90-25c6f2423868>
135136
- `-u` The generated Unicode output file will have the UTF16 Little-Endian Byte-order mark (BOM) written to it.

cmd/sqlcmd/sqlcmd.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -455,10 +455,10 @@ func normalizeFlags(cmd *cobra.Command) error {
455455
case encryptConnection:
456456
value := strings.ToLower(v)
457457
switch value {
458-
case "false", "true", "disable":
458+
case "mandatory", "yes", "1", "t", "true", "disable", "optional", "no", "0", "f", "false", "strict":
459459
return pflag.NormalizedName(name)
460460
default:
461-
err = invalidParameterError("-N", v, "false", "true", "disable")
461+
err = invalidParameterError("-N", v, "mandatory", "yes", "1", "t", "true", "disable", "optional", "no", "0", "f", "false", "strict")
462462
return pflag.NormalizedName("")
463463
}
464464
case format:

cmd/sqlcmd/sqlcmd_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ func TestInvalidCommandLine(t *testing.T) {
150150
{[]string{"-P"}, "'-P': Missing argument. Enter '-?' for help."},
151151
{[]string{"-;"}, "';': Unknown Option. Enter '-?' for help."},
152152
{[]string{"-t", "-2"}, "'-t -2': value must be greater than or equal to 0 and less than or equal to 65534."},
153+
{[]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]."},
153154
}
154155

155156
for _, test := range commands {

0 commit comments

Comments
 (0)