Commit Graph

388 Commits

Author SHA1 Message Date
Ivan Kozlovic
ce96de2ed5 [ADDED] TLS: Handshake First for client connections
A new option instructs the server to perform the TLS handshake first,
that is prior to sending the INFO protocol to the client.

Only clients that implement equivalent option would be able to
connect if the server runs with this option enabled.

The configuration would look something like this:
```
...
tls {
    cert_file: ...
    key_file: ...

    handshake_first: true
}
```

The same option can be set to "auto" or a Go time duration to fallback
to the old behavior. This is intended for deployments where it is known
that not all clients have been upgraded to a client library providing
the TLS handshake first option.

After the delay has elapsed without receiving the TLS handshake from
the client, the server reverts to sending the INFO protocol so that
older clients can connect. Clients that do connect with the "TLS first"
option will be marked as such in the monitoring's Connz page/result.
It will allow the administrator to keep track of applications still
needing to upgrade.

The configuration would be similar to:
```
...
tls {
    cert_file: ...
    key_file: ...

    handshake_first: auto
}
```
With the above value, the fallback delay used by the server is 50ms.

The duration can be explcitly set, say 300 milliseconds:
```
...
tls {
    cert_file: ...
    key_file: ...

    handshake_first: "300ms"
}
```

It is understood that any configuration other that "true" will result
in the server sending the INFO protocol after the elapsed amount of
time without the client initiating the TLS handshake. Therefore, for
administrators that do not want any data transmitted in plain text,
the value must be set to "true" only. It will require applications
to be updated to a library that provides the option, which may or
may not be readily available.

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2023-10-10 09:46:01 -06:00
Derek Collison
2737c56352 Only setup auto no-auth for $G account iff no authorization block was defined.
Signed-off-by: Derek Collison <derek@nats.io>
2023-09-28 13:51:45 -07:00
Neil Twigg
11feadfe7b Add prof_block_rate option for enabling/configuring the block profile
Signed-off-by: Neil Twigg <neil@nats.io>
2023-09-25 21:04:25 +01:00
Todd Beets
349e718d39 Changes for max log files option (active plus backups); remove redundant lexical sort of backups; adjust test 2023-09-15 22:08:09 -07:00
Todd Beets
46147cf0ea Add logfile_max_archives feature and test. 2023-09-15 16:21:51 -07:00
Derek Collison
e7e8a330d4 Allow sync intervals to be set and the ability to have all data writes synchronous.
Signed-off-by: Derek Collison <derek@nats.io>
2023-09-04 11:05:13 -07:00
Lev Brouk
ad2e9d7b8d MQTT QoS2 support 2023-08-28 11:52:01 -07:00
Derek Collison
fb8525b713 Merge branch 'main' into dev
Signed-off-by: Derek Collison <derek@nats.io>
2023-08-21 15:55:00 -07:00
Waldemar Quevedo
3a20f66535 config: parsed empty config only show warnings
Signed-off-by: Waldemar Quevedo <wally@nats.io>
2023-08-13 23:59:50 -07:00
Todd Beets
209fcd70eb OCSP Peer Feature 2023-08-02 11:25:48 -07:00
Derek Collison
42752ec551 Merge branch 'main' into dev
Signed-off-by: Derek Collison <derek@nats.io>
2023-08-01 21:46:54 -07:00
Derek Collison
b8d1ac9475 Allow long form resolver config to be of type MEM
Signed-off-by: Derek Collison <derek@nats.io>
2023-08-01 17:34:14 -07:00
Todd Beets
e51a42963a OCSP Peer Verification (#4258)
New security feature [ADR-38: OCSP Peer
Verification](https://github.com/nats-io/nats-architecture-and-design/pull/226/files#diff-575a9545de9d498a48d2889972b0cb57dbadebde3b4328b65ab02bb43f557935)
providing fine-grain certificate status check via OCSP verification; for
inbound NATS, MQTT, WebSocket, and Leaf client connections (mTLS) as
well as outbound Leaf connections to another NATS System.
2023-08-01 09:17:27 -07:00
Neil Twigg
bc78e86388 Update TestJetStreamServerReencryption to also test converting ciphers at the same time as changing keys
Signed-off-by: Neil Twigg <neil@nats.io>
2023-07-26 14:04:28 +01:00
Neil Twigg
3df08c3f89 Add support for re-encrypting streams with new key
Signed-off-by: Neil Twigg <neil@nats.io>
2023-07-26 14:04:28 +01:00
Byron Ruth
905f040d86 Change logtime_utc default to false
This ensures that the existing, default behavior of the server emitting the local timezone is not changed.
2023-07-21 16:57:12 -07:00
Neil Twigg
e88517c90e Add logtime_utc option
backport to main: https://github.com/nats-io/nats-server/pull/3833

Signed-off-by: Waldemar Quevedo <wally@nats.io>
2023-07-21 16:56:13 -07:00
Todd Beets
99dc11551b OCSP Peer Verification 2023-07-19 12:14:21 -07:00
Todd Beets
f854e95c11 Cert Store (aka wincert) 2023-06-22 12:25:54 -07:00
Tom Anderson
83a43838dc Adding option to disable jetstream ascii art
This option is not available in the config, and is only accessable to embeded servers where when using custom loggers can look pretty terrible
2023-06-21 08:04:34 -07:00
Jean-Noël Moyne
08987bd173 1: Improves error reporting for weighted mappings:
As it was, any error in a weighted mapping would return a very unhelpfull error message.

e.g. `nats-server: mappingtest.cfg:38:39: interface conversion: interface {} is []interface {}, not string`

This was because the line `err := &configErr{tk, fmt.Sprintf("Error adding mapping for %q to %q : %v", subj, v.(string), err)}` would panic on the `v.(string)` since in weighted mapping that interface{} is actually a map[string]interface{} (since there's can be more than one mapping in weighted mappings).

Now returns the actual error:

e.g. `nats-server: mappingtest.cfg:40:3: Error adding mapping for "bla" : invalid mapping destination: wildcard index out of range in {{wildcard(1)}}`

2: improves subject transform checking and catches if the destination is using a mapping function and there are no partial wildcards in the source.
Signed-off-by: Jean-Noël Moyne <jnmoyne@gmail.com>
2023-05-31 16:28:31 -07:00
Ivan Kozlovic
67498af2dc [ADDED] LeafNode: Support for s2 compression
This is similar to PR #4115 but for LeafNodes.
Compression mode can be set on both side (the accept and in remotes).
```
leafnodes {
   port: 7422
   compression: s2_best
   remotes [
       {
         url: "nats://host2:74222"
         compression: s2_better
       }
   ]
}
```
Possible modes are similar than for routes (described in PR #4115),
except that when not defined we default to `s2_auto`.

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2023-05-15 17:42:39 -06:00
Ivan Kozlovic
0a02f2121c [ADDED] LeafNode: TLSHandhsakeFirst option
A new field in `tls{}` blocks force the server to do TLS handshake
before sending the INFO protocol.
```
leafnodes {
   port: 7422
   tls {
      cert_file: ...
      ...
      handshake_first: true
   }
   remotes [
       {
         url: tls://host:7423
         tls {
            ...
            handshake_first: true
         }
       }
   ]
}
```
Note that if `handshake_first` is set in the "accept" side, the
first `tls{}` block in the example above, a server trying to
create a LeafNode connection to this server would need to have
`handshake_first` set to true inside the `tls{}` block of
the corresponding remote.

Configuration reload of leafnodes is generally not supported,
but TLS certificates can be reloaded and the support for this
new field was also added.

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2023-05-01 16:41:51 -06:00
Ivan Kozlovic
349f01e86a Change the absence of compression setting to default to "accept"
In that mode, a server accepts and will switch to same compression
level than the remote (if one is set) but will not initiate compression.
So if all servers in a cluster do not have compression setting set,
it defaults to "accept" which means that compression is "off".

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2023-04-28 15:33:17 -06:00
Ivan Kozlovic
d6fe9d4c2d [ADDED] Support for route S2 compression
The new field `compression` in the `cluster{}` block allows to
specify which compression mode to use between servers.

It can be simply specified as a boolean or a string for the
simple modes, or as an object for the "s2_auto" mode where
a list of RTT thresholds can be specified.

By default, if no compression field is specified, the server
will use the s2_auto mode with default RTT thresholds of
10ms, 50ms and 100ms for the "uncompressed", "fast", "better"
and "best" modes.

```
cluster {
..
  # Possible values are "disabled", "off", "enabled", "on",
  # "accept", "s2_fast", "s2_better", "s2_best" or "s2_auto"
  compression: s2_fast
}
```

To specify a different list of thresholds for the s2_auto,
here is how it would look like:
```
cluster {
..
  compression: {
    mode: s2_auto
    # This means that for RTT up to 5ms (included), then
    # the compression level will be "uncompressed", then
    # from 5ms+ to 15ms, the mode will switch to "s2_fast",
    # then from 15ms+ to 50ms, the level will switch to
    # "s2_better", and anything above 50ms will result
    # in the "s2_best" compression mode.
    rtt_thresholds: [5ms, 15ms, 50ms]
  }
}
```

Note that the "accept" mode means that a server will accept
compression from a remote and switch to that same compression
mode, but will otherwise not initiate compression. That is,
if 2 servers are configured with "accept", then compression
will actually be "off". If one of the server had say s2_fast
then they would both use this mode.

If a server has compression mode set (other than "off") but
connects to an older server, there will be no compression between
those 2 routes.

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2023-04-27 17:59:25 -06:00
Derek Collison
ce0d8514be Merge branch 'main' into dev 2023-04-07 05:32:05 -07:00
Derek Collison
7547093b24 _EMPTY_
Signed-off-by: Derek Collison <derek@nats.io>
2023-04-06 08:38:30 -07:00
Derek Collison
ff8701b724 Merge branch 'main' into dev 2023-04-06 08:37:11 -07:00
Julien Viard de Galbert
1b1610f2da Adding hard_delete option on resolver configuration
Signed-off-by: Julien Viard de Galbert <jviarddegalbert@scaleway.com>
2023-04-05 10:05:48 +02:00
Ivan Kozlovic
83c5c0177a Changes based on code review
Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2023-04-03 09:32:28 -06:00
Ivan Kozlovic
105237cba8 [ADDED] Multiple routes and ability to have per-account routes
New configuration fields:
```
cluster {
   ...
   pool_size: 5
   accounts: ["A", "B"]
}
```

The configuration `pool_size` in the example above means that this
server will create 5 routes to a remote server, assuming that that
server has the same `pool_size` setting.

Accounts (which are not part of the `accounts[]` configuration)
are assigned a specific route in this pool, and this will be the
same route on all servers in the cluster.

Accounts that are defined in the `accounts` field will each have
a dedicated route connection. This will allow suppression of the
account name in some of the route protocols, reducing bytes transmitted
which may increase performance.

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2023-04-03 09:32:25 -06:00
Byron Ruth
7f7c71764d Change logtime_utc default to false
This ensures that the existing, default behavior of the server emitting the local timezone is not changed.
2023-02-28 12:57:36 -05:00
Neil Twigg
01a02f2382 Add logtime_utc option 2023-02-10 10:29:26 +00:00
Derek Collison
dcf9f1a87f Merge pull request #3802 from nats-io/wincert
certstore feature with windows credential manager
2023-01-26 09:43:40 -08:00
Derek Collison
469116deae Merge branch 'main' into dev 2023-01-26 09:39:32 -08:00
Todd Beets
e1fd61778f certstore feature with windows credential manager 2023-01-25 21:22:20 -08:00
Derek Collison
4a3c27a251 Fix MQTT test for consumer replica override.
This was ill-advised by me, not understanding that the messages stream for MQTT was interested policy based.
Interest policy based streams require consumers to match the replica count.

Signed-off-by: Derek Collison <derek@nats.io>
2023-01-25 17:58:57 -08:00
Derek Collison
2daf90493b Authentication and Authorization callouts for server configuration mode.
This adds the ability to augment or override the NATS auth system.

A server will send a signed request to $SYS.REQ.USER.AUTH on the specified account. The request will contain client information, all client options sent to the server, and optionally TLS information and client certificates.
The external auth service will respond with an empty message if not authorized, or a signed User JWT that the user will bind to.

The response can change the account the client will be bound to.

Signed-off-by: Derek Collison <derek@nats.io>
2022-12-28 10:32:45 -08:00
Derek Collison
90c7df2a59 Merge branch 'main' into dev
Signed-off-by: Derek Collison <derek@nats.io>
2022-12-06 04:03:55 -08:00
Byron Ruth
d55ec395a3 Update --signal usage help
This includes `ldm` and `term`.

Signed-off-by: Byron Ruth <b@devel.io>
2022-12-06 06:45:00 -05:00
Derek Collison
62ce2e46ab Remove "" and replace with _EMPTY_
Signed-off-by: Derek Collison <derek@nats.io>
2022-11-27 13:59:05 -08:00
Ivan Kozlovic
ed4bb282f6 Rename config param to max_outstanding_catchup
Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2022-08-30 14:51:34 -06:00
Ivan Kozlovic
9a6a2c31ee [ADDED] JetStream: Ability to configure the per server max catchup bytes
The original value was hardcoded to 128MB and 32MB per stream. The
per-server limit is lowered to 32MB but is configurable with
a new configuration parameter:
```
jetstream {
   max_catchup: 8MB
}
```

The per-stream limit was also lowered from 32MB/128,000msgs to
8MB/32,000 messages.

Tests have shown no difference in performance for fast links.

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2022-08-30 13:46:13 -06:00
Derek Collison
827b34a77a Add support for AES cipher encryption for filestore.
Signed-off-by: Derek Collison <derek@nats.io>
2022-08-15 14:21:37 -07:00
Ivan Kozlovic
d90854a45f Merge pull request #3341 from nats-io/go_1_19
Move to Go 1.19, remote io/util, fix data race and a flapper
2022-08-05 12:49:06 -06:00
Ivan Kozlovic
3c9a7cc6e5 Move to Go 1.19, remote io/util, fix data race and a flapper
Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2022-08-05 09:55:37 -06:00
Ivan Kozlovic
7baf7bd887 [ADDED] LeafNode: Support for a SignatureHandler in remote config
This would allow in embedded use-cases where the user does not
have the ability to use a credentials file. Instead, a signature
callback is specified and invoked by the server sends the CONNECT
protocol. The user is responsible to provide the JWT and sign the
nonce.

Resolves #3331

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2022-08-04 16:59:09 -06:00
Derek Collison
c14fda51e7 Direct access to JetStream resources would be affected if across a leafnode that was down.
This allows a solciting leafnode config to ask that any JetStream cluster assets that are a current leader have the leader stepdown.

Signed-off-by: Derek Collison <derek@nats.io>
2022-07-05 12:35:09 -07:00
Neil Alexander
e9abc5801e Add InProcessConn, DontListen 2022-06-28 17:02:47 +01:00
Derek Collison
9400733606 Allow for MQTT QoS-1 consumers to be auto cleanup after inactive threshold of time.
Signed-off-by: Derek Collison <derek@nats.io>
2022-06-14 17:37:45 -07:00