TLS Error: local/remote TLS keys are out of sync
Hello,
when using the master branch I get the following output on the server upon renegotiation, when using deferred auth:
2021-06-14 02:15:50 client/10.10.10.2:1194 TLS Error: local/remote TLS
keys are out of sync: [AF_INET6]::ffff:10.10.10.2:1194 (received key id:
6, known key ids: [key#0 state=S_ACTIVE auth=KS_AUTH_DEFERRED id=6 sid=bbb535c3 f49bfb24] [key#1 state=S_ACTIVE auth=KS_AUTH_TRUE id=5 sid=bbb535c3 f49bfb24] [key#2 state=S_UNDEF auth=KS_AUTH_FALSE id=0 sid=00000000 00000000])
2021-06-14 02:15:51 client/10.10.10.2:1194 TLS Error: local/remote TLS
keys are out of sync: [AF_INET6]::ffff:10.10.10.2:1194 (received key id:
6, known key ids: [key#0 state=S_ACTIVE auth=KS_AUTH_DEFERRED id=6 sid=bbb535c3 f49bfb24] [key#1 state=S_ACTIVE auth=KS_AUTH_TRUE id=5 sid=bbb535c3 f49bfb24] [key#2 state=S_UNDEF auth=KS_AUTH_FALSE id=0 sid=00000000 00000000])
2021-06-14 02:15:52 client/10.10.10.2:1194 TLS Error: local/remote TLS
keys are out of sync: [AF_INET6]::ffff:10.10.10.2:1194 (received key id:
6, known key ids: [key#0 state=S_ACTIVE auth=KS_AUTH_DEFERRED id=6 sid=bbb535c3 f49bfb24] [key#1 state=S_ACTIVE auth=KS_AUTH_TRUE id=5 sid=bbb535c3 f49bfb24] [key#2 state=S_UNDEF auth=KS_AUTH_FALSE id=0 sid=00000000 00000000])
2021-06-14 02:15:53 client/10.10.10.2:1194 TLS Error: local/remote TLS
keys are out of sync: [AF_INET6]::ffff:10.10.10.2:1194 (received key id:
6, known key ids: [key#0 state=S_ACTIVE auth=KS_AUTH_DEFERRED id=6 sid=bbb535c3 f49bfb24] [key#1 state=S_ACTIVE auth=KS_AUTH_TRUE id=5 sid=bbb535c3 f49bfb24] [key#2 state=S_UNDEF auth=KS_AUTH_FALSE id=0 sid=00000000 00000000])
2021-06-14 02:15:54 client/10.10.10.2:1194 TLS Error: local/remote TLS
keys are out of sync: [AF_INET6]::ffff:10.10.10.2:1194 (received key id:
6, known key ids: [key#0 state=S_ACTIVE auth=KS_AUTH_DEFERRED id=6 sid=bbb535c3 f49bfb24] [key#1 state=S_ACTIVE auth=KS_AUTH_TRUE id=5 sid=bbb535c3 f49bfb24] [key#2 state=S_UNDEF auth=KS_AUTH_FALSE id=0 sid=00000000 00000000])
2021-06-14 02:15:55 client/10.10.10.2:1194 TLS Error: local/remote TLS
keys are out of sync: [AF_INET6]::ffff:10.10.10.2:1194 (received key id:
6, known key ids: [key#0 state=S_ACTIVE auth=KS_AUTH_DEFERRED id=6 sid=bbb535c3 f49bfb24] [key#1 state=S_ACTIVE auth=KS_AUTH_TRUE id=5 sid=bbb535c3 f49bfb24] [key#2 state=S_UNDEF auth=KS_AUTH_FALSE id=0 sid=00000000 00000000])
2021-06-14 02:15:56 client/10.10.10.2:1194 TLS Error: local/remote TLS
keys are out of sync: [AF_INET6]::ffff:10.10.10.2:1194 (received key id:
6, known key ids: [key#0 state=S_ACTIVE auth=KS_AUTH_DEFERRED id=6 sid=bbb535c3 f49bfb24] [key#1 state=S_ACTIVE auth=KS_AUTH_TRUE id=5 sid=bbb535c3 f49bfb24] [key#2 state=S_UNDEF auth=KS_AUTH_FALSE id=0 sid=00000000 00000000])
The situation gets fixed by itself in a bunch of seconds.
I wonder if this has anything to do with the cached auth not increasing some state, while the key has been substituted.
It seems to be reproducible very easily.
@Arne, ideas?
I start the server this way:
${OVPN} \
--server 10.10.0.0 255.255.255.0 \
--dev tun \
--cipher AES-256-GCM \
--peer-fingerprint ${FP} \
--cert ${CERT} --key ${KEY} \
--verb 3 --dh none --auth-user-pass-verify auth.sh via-env--script-security 3
and the client this way:
${OVPN} --dev tun --client --remote 10.10.10.1 \
--cipher AES-256-GCM \
--peer-fingerprint ${FP} \
--cert ${CERT} --key ${KEY} --verb 3 --reneg-sec 20 --auth-user-passauth.sh is the following:
#!/bin/bash
echo PASS=$password
echo FILE=$auth_control_file
(
sleep 5
if [ "$password" = "testyes" ]; then
echo SUCCESS
if [ -n "$auth_control_file" ]; then
echo 1 >$auth_control_file
fi
exit 0
fi
echo FAIL
if [ -n "$auth_control_file" ]; then
echo 0 >$auth_control_file
fi
exit 1
)&
exit 2
I use this test setup since a while and I did not get any error like this in the past.
If nobody has any idea I can try to bisect and see when this started.
Regards,
Signature · 1 line
Antonio Quartulli
Am 14.06.21 um 02:24 schrieb Antonio Quartulli:
Quoted 2 lines
@Arne, ideas?
Yes. When reneg-sec is below 60 or 120 (would need to double check), you need that value on both server and client since otherwise the timeouts for changing active keys mismatch as the value is 60s normally but changes if reneg-sec goes below that value.
Quoted 17 lines
I start the server this way:
${OVPN} \ --server 10.10.0.0 255.255.255.0 \ --dev tun \ --cipher AES-256-GCM \ --peer-fingerprint ${FP} \ --cert ${CERT} --key ${KEY} \ --verb 3 --dh none --auth-user-pass-verify auth.sh via-env--script-security 3
and the client this way:
${OVPN} --dev tun --client --remote 10.10.10.1 \ --cipher AES-256-GCM \ --peer-fingerprint ${FP} \ --cert ${CERT} --key ${KEY} --verb 3 --reneg-sec 20 --auth-user-pass
Hi,
Quoted 8 lines · Arne Schwabe
Am 14.06.21 um 02:24 schrieb Antonio Quartulli:
Quoted 2 lines
@Arne, ideas?
Yes. When reneg-sec is below 60 or 120 (would need to double check), you need that value on both server and client since otherwise the timeouts for changing active keys mismatch as the value is 60s normally but changes if reneg-sec goes below that value.
Isn't it relevant that the server is able to fix itself in around 5/6 seconds? It does not need to wait for the full 60s to get back in sync.
From the log it also seems like the key with the new ID has been installed, but the state has not been switched.
Regards,
Signature · 1 line
Antonio Quartulli
Am 14.06.21 um 03:01 schrieb Antonio Quartulli:
Quoted 12 lines
Hi,
Quoted 8 lines · Arne Schwabe
Am 14.06.21 um 02:24 schrieb Antonio Quartulli:
Quoted 2 lines
@Arne, ideas?
Yes. When reneg-sec is below 60 or 120 (would need to double check), you need that value on both server and client since otherwise the timeouts for changing active keys mismatch as the value is 60s normally but changes if reneg-sec goes below that value.
Quoted 6 lines
Isn't it relevant that the server is able to fix itself in around 5/6 seconds? It does not need to wait for the full 60s to get back in sync.
From the log it also seems like the key with the new ID has been installed, but the state has not been switched.
From the logs it looks like the key is still in deferred auth (uth=KS_AUTH_DEFERRED), as you can see from the state, so the server cannot use it for decryption yet.
reneg-sec 20 on client means that the client will switch to the new key after 10s. With deferred auth in the mix on the server side that is a bit tight. If the server has not authenticated that key yet, you will see the out of sync messages.
Arne
Hi,
Quoted 20 lines · Arne Schwabe
Am 14.06.21 um 03:01 schrieb Antonio Quartulli:
Quoted 12 lines
Hi,
Quoted 8 lines · Arne Schwabe
Am 14.06.21 um 02:24 schrieb Antonio Quartulli:
Quoted 2 lines
@Arne, ideas?
Yes. When reneg-sec is below 60 or 120 (would need to double check), you need that value on both server and client since otherwise the timeouts for changing active keys mismatch as the value is 60s normally but changes if reneg-sec goes below that value.
Quoted 6 lines
Isn't it relevant that the server is able to fix itself in around 5/6 seconds? It does not need to wait for the full 60s to get back in sync.
From the log it also seems like the key with the new ID has been installed, but the state has not been switched.
Quoted 8 lines
From the logs it looks like the key is still in deferred auth (uth=KS_AUTH_DEFERRED), as you can see from the state, so the server cannot use it for decryption yet.
reneg-sec 20 on client means that the client will switch to the new key after 10s. With deferred auth in the mix on the server side that is a bit tight. If the server has not authenticated that key yet, you will see the out of sync messages.
Ok, after clarifying in chat, I understood that the time needed by a peer to elect a key as "usable" is defined by auth_deferred_expire_window().
If reneg-sec is smaller than hand-window (which is 60s by default) then we can have this particular situation.
Now, we are assuming that hand-window is always the same on both peers (client and server), but actually this value may also be customized and mess everything up.
Changing hand-window on one peer only is not a good idea in any case.
At this point I'd ask, why not re-moving/ignoring --hand-window entirely and live with the 60s default?
Regards,
Signature · 1 line
Antonio Quartulli
Quoted 7 lines
Ok, after clarifying in chat, I understood that the time needed by a peer to elect a key as "usable" is defined by
auth_deferred_expire_window().If reneg-sec is smaller than hand-window (which is 60s by default) then we can have this particular situation.
Quoted 8 lines
Now, we are assuming that hand-window is always the same on both peers (client and server), but actually this value may also be customized and mess everything up.
Changing hand-window on one peer only is not a good idea in any case.
At this point I'd ask, why not re-moving/ignoring --hand-window entirely and live with the 60s default?
That is one of the many question why so many protocol things in OpenVPN are finetunable in the first place. We can certainly add warnings when setting these saying that this option should be only used for debugging. And do the same for reneg-sec when set < 120 (or more accurately 2*hand-window)
Arne
Hi,
Quoted 9 lines · Arne Schwabe
Quoted 2 lines
At this point I'd ask, why not re-moving/ignoring --hand-window entirely and live with the 60s default?
That is one of the many question why so many protocol things in OpenVPN are finetunable in the first place. We can certainly add warnings when setting these saying that this option should be only used for debugging. And do the same for reneg-sec when set < 120 (or more accurately 2*hand-window)
When a knob is there, no matter if for debugging or not, people will just use it.
It may break things, which may create rumors, which may create support overhead.
IMHO going with well declared constant values (i.e. in a nicely commented header file), which can be easily tweaked by a developer before recompiling the OpenVPN, are more than enough for debugging (check [1] for an example).
This way you clearly make the bar for shooting yourself in the foot high enough so that only skilled snipers can do that.
Cheers,
[1]
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/net/batman-adv/main.h
Signature · 1 line
Antonio Quartulli
Am 14.06.21 um 16:21 schrieb Antonio Quartulli:
Quoted 18 lines
Hi,
Quoted 9 lines · Arne Schwabe
Quoted 2 lines
At this point I'd ask, why not re-moving/ignoring --hand-window entirely and live with the 60s default?
That is one of the many question why so many protocol things in OpenVPN are finetunable in the first place. We can certainly add warnings when setting these saying that this option should be only used for debugging. And do the same for reneg-sec when set < 120 (or more accurately 2*hand-window)
When a knob is there, no matter if for debugging or not, people will just use it.
It may break things, which may create rumors, which may create support overhead.
Quoted 8 lines
IMHO going with well declared constant values (i.e. in a nicely commented header file), which can be easily tweaked by a developer before recompiling the OpenVPN, are more than enough for debugging (check [1] for an example).
This way you clearly make the bar for shooting yourself in the foot high enough so that only skilled snipers can do that.
Put on the agenda for community meeting to decide if we want to deprecate hand-window compeletely and reneg-sec under < 120?
Arne
Quoted 3 lines · Arne Schwabe
Put on the agenda for community meeting to decide if we want to deprecate hand-window compeletely and reneg-sec under < 120?
Good idea! will do!
Cheers,
Signature · 1 line
Antonio Quartulli
Hi,
Quoted 7 lines · Antonio Quartulli
Quoted 3 lines · Arne Schwabe
Put on the agenda for community meeting to decide if we want to deprecate hand-window compeletely and reneg-sec under < 120?
Good idea! will do!
I used to have some remote clients on low bandwidth high latency (and often erratic) satellite link for which the initial handshake was pretty taxing on the network. Like 15 to 30 seconds to complete the handshake on good days. But the tunnel stayed up most of the time once connected, even through desert storms[1] that adversely affect the up link. Renegotiation seldom failed probably because tran-window is long by default. Since then I generally set --hand-window to 120, though not sure such a large value was ever really required or helped.
Saying this only to point out there may be some situations where an option to increase the handshake timeout is useful. For reneg-sec I don't think there is any strong reason to allow arbitrarily low values. Even 120 sec is useful only for testing purposes.
Selva
[1] The client was in a remote mining site with harsh weather.