Skip to content

Commit

Permalink
nats-io#181 support TLS Insecure connection - added flag --tlsinsecure
Browse files Browse the repository at this point in the history
  • Loading branch information
mschneider82 committed Jul 25, 2024
1 parent 7b97b33 commit e8d44f4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cli/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,10 @@ func natsOpts() []nats.Option {
connectionName = "NATS CLI Version " + Version
}

if opts().TlsInsecure {
copts = append(copts, nats.Secure(&tls.Config{InsecureSkipVerify: true}))
}

return append(copts, []nats.Option{
nats.Name(connectionName),
nats.MaxReconnects(-1),
Expand Down
1 change: 1 addition & 0 deletions nats/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ See 'nats cheat' for a quick cheatsheet of commands`
ncli.Flag("tlskey", "TLS private key").Envar("NATS_KEY").PlaceHolder("FILE").ExistingFileVar(&opts.TlsKey)
ncli.Flag("tlsca", "TLS certificate authority chain").Envar("NATS_CA").PlaceHolder("FILE").ExistingFileVar(&opts.TlsCA)
ncli.Flag("tlsfirst", "Perform TLS handshake before expecting the server greeting").BoolVar(&opts.TlsFirst)
ncli.Flag("tlsinsecure", "Disable TLS Certificate Verification").BoolVar(&opts.TlsInsecure)
if runtime.GOOS == "windows" {
ncli.Flag("certstore", "Uses a Windows Certificate Store for TLS (user, machine)").PlaceHolder("TYPE").EnumVar(&opts.WinCertStoreType, "user", "windowscurrentuser", "machine", "windowslocalmachine")
ncli.Flag("certstore-match", "Which certificate to use in the store").PlaceHolder("QUERY").StringVar(&opts.WinCertStoreMatch)
Expand Down
2 changes: 2 additions & 0 deletions options/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ type Options struct {
TlsKey string
// TlsCA is the certificate authority to verify the connection with
TlsCA string
// TlsInsecure Disable TLS Certificate Verification
TlsInsecure bool
// Timeout is how long to wait for operations
Timeout time.Duration
// ConnectionName is the name to use for the underlying NATS connection
Expand Down

0 comments on commit e8d44f4

Please sign in to comment.