Commit Graph

392 Commits

Author SHA1 Message Date
Alan Jowett
c53cc97395 Close fd and stop ev_io on failed handshake.
Signed-off-by: Alan Jowett <alanjo@microsoft.com>
2021-02-04 10:18:34 -07:00
Nikos Mavrogiannopoulos
acf31f5dde parse_data: print unknown bye packets
Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
2020-12-27 21:58:18 +01:00
Nikos Mavrogiannopoulos
47c6638286 ocserv-worker: renamed loop to worker_loop
This avoids warnings and static analyzers complains about
the libev functions hiding the global 'loop' variable

Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
2020-12-12 22:41:57 +01:00
Daniel Lenski
dd34f85875 OpenConnect will interpret these headers once https://gitlab.com/openconnect/openconnect/-/merge_requests/156 is merged
Examples of newly-authenticated sessions from Cisco servers:

- Default value of `Session-Timeout` is 1209600 seconds (14 days) per
  https://www.cisco.com/assets/sol/sb/RV345P_Emulators/RV345P_Emulator_v1-0-01-17/help/help/t_SSL_VPN.html
- https://www.mail-archive.com/openconnect-devel@lists.infradead.org/msg00968.html:
  `Lease-Duration` having the default value, while `Session-Timeout`
  and `Session-Timeout-Remaining` are `none`
- https://gitlab.com/openconnect/openconnect/-/issues/43#note_177677716:
  `Lease-Duration`, `Session-Timeout`, and `Session-Timeout-Remaining` all with
  same value

My own testing of *reconnected* sessions (on a newer Cisco server supporting
DTLS 1.2) shows that Session-Timeout-Remaining will have a value less than
Session-Timeout, such that the expiration timestamp remains constant from one
reconnection to the next.

Signed-off-by: Daniel Lenski <dlenski@amazon.com>
2020-12-09 17:27:00 -08:00
Russ Young
3055c15c96 Log changes to reduce logging noise
Signed-off-by: Russell Young <ruyoung@microsoft.com>
2020-12-03 10:58:22 +01:00
Nikos Mavrogiannopoulos
57c0381269 send_stats_to_secmod: silence coverity
Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
2020-11-26 14:22:17 +01:00
Nikos Mavrogiannopoulos
3be9234cb9 gnutls_rnd(): always check its return value
Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
2020-11-19 22:20:19 +01:00
Alan Jowett
01a9815bdf Set disconnect reason when updating ban-ip
Resolves: #360

Signed-off-by: Alan Jowett alan.jowett@microsoft.com
2020-11-06 13:16:32 -07:00
Alan Jowett
3436705a9c Allow setup of new DTLS session while processing on old session
Resolves: #359

Signed-off-by: Alan Jowett alan.jowett@microsoft.com
2020-10-19 10:36:03 -06:00
Alan Jowett
7a924b6d9c Don't attempt TLS if the client closes the connection with zero data sent.
Resolves #357

Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>
2020-09-30 16:03:38 -06:00
Alan Jowett
34eab81339 Resolves: #326
Pass the hostname to ocserv-main after receiving the connect request.

Signed-off-by: Alan Jowett <alanjo@microsoft.com>
2020-07-28 13:37:20 -06:00
Nikos Mavrogiannopoulos
8aa39b0106 Improved user disconnection to avoid race conditions
Previously when we were disconnecting a user there were few seconds
after which the cookie was still valid, so a reconnect would succeed
by the same user. This change ensures that a disconnected (via occtl)
user cannot re-use the same cookie to connect. That enables a safe
user removal from the authentication database, and from run-time.

Resolves: #59

Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
2020-07-25 21:38:55 +02:00
Nikos Mavrogiannopoulos
ce89e0f582 Ensure that unchecked function calls are for a reason and fix otherwise
Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
2020-06-30 21:53:34 +02:00
Nikos Mavrogiannopoulos
62cd787536 Log X-DTLS-App-ID and X-DTLS-Session-ID when sent
Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
2020-06-08 10:41:22 +02:00
Alan Jowett
722e030e58 Add reporting of RX latency
Resolve: #258

Signed-off-by: Alan Jowett <alanjo@microsoft.com>
2020-05-26 18:14:36 -06:00
Alan Jowett
75470d99c3 When setting up the DTLS session, close the previous DTLS session if it exists.
Resolves: #293

Signed-off-by: Alan Jowett alanjo@microsoft.com
2020-04-29 13:39:28 +02:00
Alan Jowett
7e5052782e Remove unused code when --disable-compression is set.
Resolves: #291

Singed-off-by: Alan Jowett <alanjo@microsoft.com>
2020-04-27 09:18:09 -06:00
Nikos Mavrogiannopoulos
e79348a154 corrected typo
Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
2020-04-17 22:14:58 +02:00
Nikos Mavrogiannopoulos
a63164e182 Disable TCP queuing on the TLS port.
This makes the CSTP connection more interactive for clients that
cannot run over UDP.

See openconnect#122 for discussion.

Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
2020-04-10 21:15:39 +02:00
Nikos Mavrogiannopoulos
fca41e2fa2 Distinguish the bye packet interpretation
In openconnect client the BYE packet indicates an explicit
user disconnect by sending 0x0b as payload. In anyconnect clients it
may indicate an intention to reconnect (e.g., because network was changed).
We introduce a check for 0x0b to identify the user disconnect and
add debugging output for other disconnect reasons.

Relates: #281

Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
2020-04-08 21:07:36 +02:00
Nikos Mavrogiannopoulos
3475e2b0fc Provide a special IPv6 route for iOS
When IPv6 is requested by iphone we provide a special route that is
necessary by these clients to use IPv6.

Resolves: #254

Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
2020-03-15 13:23:37 +01:00
Alan Jowett
c9662282a1 Prevent tampering of our_ip, ip, session_start_time in SEC_AUTH_INIT from ocserv-worker to ocserv->sm and reject replay of auth_init_messages from old sessions.
Resolves: #252

Signed-off-by: Alan Jowett <alanjo@microsoft.com>
2020-02-28 11:20:30 -07:00
Nikos Mavrogiannopoulos
4bcf29643d ocserv: added support for per-user split-dns directive
Resolves: #229

Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
2019-11-17 11:06:47 +01:00
Leendert van Doorn
f73269175a AnyConnect clients expect a different verb (X-CSTP-DNS-IP6) for passing IPv6 DNS addresses.
Signed-off-by: Leendert van Doorn <leendert@paramecium.org>
Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
2019-11-17 09:07:16 +01:00
Leendert van Doorn
e9b79254e7 Detect AnyConnect clients and allow IPV6 routes to be passed through.
Signed-off-by: Leendert van Doorn <leendert@paramecium.org>
Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
2019-11-17 09:01:53 +01:00
Nikos Mavrogiannopoulos
8ba3987f4c occtl: print the TLS session information, even if no DTLS channel
This ensures that the main process receives the TLS channel information
early and does not depend on DTLS channel establishment. Furthermore,
we refactor to make setup_dtls_psk_keys() fail early when no TLS channel
is available.

Signed-off-by: Nikos Mavrogiannopoulos <nmav@gnutls.org>
2019-01-19 20:09:53 +01:00
Nikos Mavrogiannopoulos
e0f847b984 worker: added safety check for selected DTLS ciphersuite prior to use
This avoids a crash when no DTLS ciphersuite is selected and adds a
test case for negotiation without DTLS.

Signed-off-by: Nikos Mavrogiannopoulos <nmav@gnutls.org>
2019-01-19 18:19:11 +01:00
Nikos Mavrogiannopoulos
ec5ebd33a4 setup_dtls0_9_keys: renamed and updated log messages for clarity
Signed-off-by: Nikos Mavrogiannopoulos <nmav@gnutls.org>
2019-01-10 13:03:03 +01:00
Nikos Mavrogiannopoulos
acdd6d156b worker-http: added support for anyconnect DTLS1.2 ciphersuites
This adds support for DTLS1.2 ciphersuite header as sent by anyconnect
clients.

Resolves #188
Resolves #193

Signed-off-by: Nikos Mavrogiannopoulos <nmav@gnutls.org>
2019-01-10 13:02:40 +01:00
pumpkin031
34b39d213c Add logging output when IPv6 is disabled.
Signed-off-by: pumpkin031 <www.carrotsoft@gmail.com>
2018-11-19 10:04:29 +09:00
Nikos Mavrogiannopoulos
52c3a9fd09 worker-vpn: more reasonable messages for timeout and disconnections
Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
2018-06-19 16:52:23 +02:00
Nikos Mavrogiannopoulos
b4b3f8978d tlslib: eliminated unneeded code for GnuTLS >= 3.3.0
We already require GnuTLS 3.3.0 or later.

Signed-off-by: Nikos Mavrogiannopoulos <nmav@gnutls.org>
2018-04-14 14:23:09 +02:00
Nikos Mavrogiannopoulos
56a2d4b7e4 use casts to avoid various clang warnings under BSD systems
Signed-off-by: Nikos Mavrogiannopoulos <nmav@gnutls.org>
2018-03-10 17:56:12 +01:00
Nikos Mavrogiannopoulos
ba6921ed9a Introduced the notion of virtual hosts
This provides virtualized server configurations which take
effect after client connection when client hello is received.

Signed-off-by: Nikos Mavrogiannopoulos <nmav@gnutls.org>
2018-03-06 20:42:31 +01:00
Nikos Mavrogiannopoulos
ee1cada66a worker: check for POLLERR condition
When checking the events returned from poll, handle the POLLERR
condition. This fixes an infinite loop on the worker's main
loop.

Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
2018-01-16 16:20:32 +01:00
Nikos Mavrogiannopoulos
d5a4c2914c dtls: do increase handshake timeout and decrease retransmission time
That in effect enables the default timeouts described in
gnutls_dtls_set_timeouts which are 60 seconds, and sets
retransmissions to occur in half a second.

Relates #122

Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
2017-11-30 15:53:56 +01:00
Nikos Mavrogiannopoulos
67991e6960 removed dead assignments
Signed-off-by: Nikos Mavrogiannopoulos <nmav@gnutls.org>
2017-09-07 21:57:31 +02:00
Nikos Mavrogiannopoulos
89ba65922a Avoid the use of the VERS-ALL priority string when gnutls < 3.3.24 is present
That priority string is only available on gnutls 3.3.24+ versions of gnutls.

Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
2017-05-18 08:27:02 +02:00
Nikos Mavrogiannopoulos
9938056f6c Disable DTLS-PSK protocol when run under a unix socket
It is not possible to derive PSK keys when only the TCP CSTP session
is available, without the TLS session.

Relates #22

Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
2017-03-20 09:27:46 +01:00
Nikos Mavrogiannopoulos
4d9cdf7610 worker-vpn: use TCP_INFO on linux to obtain accurate MTU information
This provides a more accurate value than the one obtained using the
TCP MSS value. The latter is affected by many factors (such as tcp
options), to provide a reliable value.

Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
2017-02-23 10:05:45 +01:00
Nikos Mavrogiannopoulos
fdfad2fa7e worker-vpn: corrected calculation for MTU via TCP MSS
Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
2017-02-22 22:01:49 +01:00
Andrew Patrikalakis
69261b6aa8 Automatically switch to TCP in case of no received UDP traffic
and enable by default
2016-11-01 19:53:33 -07:00
Nikos Mavrogiannopoulos
5fce6c8c86 Use the X-AnyConnect-Identifier-Platform header to identify mobile clients
That is, if the header contains "android" or "apple-ios" mark it as
a mobile client. The header X-AnyConnect-Identifier-DeviceType is only
considered for logging purposes and appended to the user-agent name
if present.
2016-09-25 15:44:43 +02:00
Nikos Mavrogiannopoulos
445b9070a6 untied the cisco-client-compat option from the DTLS-LEGACY protocol
Introduced instead the 'dtls-legacy' config option which can be used
to explicitly disable the legacy DTLS protocol.
2016-09-22 15:43:50 +02:00
Nikos Mavrogiannopoulos
bd87c7607e renamed match-tls-and-dtls-ciphers to match-tls-dtls-ciphers 2016-09-22 15:26:02 +02:00
Nikos Mavrogiannopoulos
4c85fa97f0 Added configuration option 'dtls-psk'
When this option is set to false, the DTLS-PSK protocol
will not be negotiated by worker processes. The process will fallback
to the legacy protocol in that case.
2016-09-22 15:20:35 +02:00
Nikos Mavrogiannopoulos
33089ab74e Updated the new DTLS protocol negotiation
The server sends the X-DTLS-App-ID header in the new protocol;
the X-DTLS-Session-ID is only used in the legacy protocol. The
server expects the Application identifier to be placed in a TLS
extension.
2016-09-21 08:53:35 +02:00
Nikos Mavrogiannopoulos
0a4e06b354 Only send the X-DTLS-MTU in the legacy protocol
There the DTLS ciphersuite and DTLS version are negotiated and
we cannot accurately predict the actual tunnel size. In that
case the client must rely on the Base-MTU.
2016-09-14 13:12:05 +02:00
Nikos Mavrogiannopoulos
58b447c413 Use a macro for the DTLS-PSK protocol indicator
Also corrected its usage in worker-http
2016-09-13 14:09:59 +02:00
Nikos Mavrogiannopoulos
b0dcea76ca Modified the X-DTLS-CipherSuite parameter for PSK to PSK-NEGOTIATE
This was changed so that it is explicitly made incompatible with
existing openconnect patch. The new openconnect client patch for
PSK negotiation is incompatible with the protocol as implemented
in 0.11.4 and requires the option match-tls-and-dtls-ciphers for its
openssl variant.
2016-09-13 13:41:46 +02:00