Skip to content

Commit 802fcce

Browse files
itsGiaancron2
authored andcommitted
Persist-key: enable persist-key option by default
Change the default behavior of the OpenVPN configuration by enabling the persist-key option by default. This means that all the keys will be kept in memory across restart. Trac: #1405 Change-Id: I57f1c2ed42bd9dfd43577238749a9b7f4c1419ff Signed-off-by: Gianmarco De Gregori <[email protected]> Message-Id: <[email protected]> URL: https://www.mail-archive.com/[email protected]/msg28347.html Signed-off-by: Gert Doering <[email protected]>
1 parent 15b7403 commit 802fcce

14 files changed

+24
-47
lines changed

Changes.rst

+2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ NTLMv1 authentication support for HTTP proxies has been removed.
2020
When configured to authenticate with NTLMv1 (``ntlm`` keyword in
2121
``--http-proxy``) OpenVPN will try NTLMv2 instead.
2222

23+
``persist-key`` option has been enabled by default.
24+
All the keys will be kept in memory across restart.
2325

2426
Overview of changes in 2.6
2527
==========================

doc/man-sections/connection-profiles.rst

-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ Here is an example of connection profile usage::
3939
http-proxy 192.168.0.8 8080
4040
</connection>
4141

42-
persist-key
4342
persist-tun
4443
pkcs12 client.p12
4544
remote-cert-tls server

doc/man-sections/generic-options.rst

+1-12
Original file line numberDiff line numberDiff line change
@@ -302,17 +302,6 @@ which mode OpenVPN is configured as.
302302
Change process priority after initialization (``n`` greater than 0 is
303303
lower priority, ``n`` less than zero is higher priority).
304304

305-
--persist-key
306-
Don't re-read key files across :code:`SIGUSR1` or ``--ping-restart``.
307-
308-
This option can be combined with ``--user`` to allow restarts
309-
triggered by the :code:`SIGUSR1` signal. Normally if you drop root
310-
privileges in OpenVPN, the daemon cannot be restarted since it will now
311-
be unable to re-read protected key files.
312-
313-
This option solves the problem by persisting keys across :code:`SIGUSR1`
314-
resets, so they don't need to be re-read.
315-
316305
--providers providers
317306
Load the list of (OpenSSL) providers. This is mainly useful for using an
318307
external provider for key management like tpm2-openssl or to load the
@@ -402,7 +391,7 @@ which mode OpenVPN is configured as.
402391

403392
Like with chroot, complications can result when scripts or restarts are
404393
executed after the setcon operation, which is why you should really
405-
consider using the ``--persist-key`` and ``--persist-tun`` options.
394+
consider using the ``--persist-tun`` option.
406395

407396
--status args
408397
Write operational status to ``file`` every ``n`` seconds. ``n`` defaults

doc/man-sections/link-options.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ the local and the remote host.
283283
See the signals section below for more information on :code:`SIGUSR1`.
284284

285285
Note that the behavior of ``SIGUSR1`` can be modified by the
286-
``--persist-tun``, ``--persist-key``, ``--persist-local-ip`` and
286+
``--persist-tun``, ``--persist-local-ip`` and
287287
``--persist-remote-ip`` options.
288288

289289
Also note that ``--ping-exit`` and ``--ping-restart`` are mutually

doc/man-sections/server-options.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ fast hardware. SSL/TLS authentication must be used in this mode.
452452
``--route``, ``--route-gateway``, ``--route-delay``,
453453
``--redirect-gateway``, ``--ip-win32``, ``--dhcp-option``, ``--dns``,
454454
``--inactive``, ``--ping``, ``--ping-exit``, ``--ping-restart``,
455-
``--setenv``, ``--auth-token``, ``--persist-key``, ``--persist-tun``,
455+
``--setenv``, ``--auth-token``, ``--persist-tun``,
456456
``--echo``, ``--comp-lzo``, ``--socket-flags``, ``--sndbuf``,
457457
``--rcvbuf``, ``--session-timeout``
458458

doc/man-sections/signals.rst

+2-3
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,8 @@ SIGNALS
1010
Like :code:`SIGHUP``, except don't re-read configuration file, and
1111
possibly don't close and reopen TUN/TAP device, re-read key files,
1212
preserve local IP address/port, or preserve most recently authenticated
13-
remote IP address/port based on ``--persist-tun``, ``--persist-key``,
14-
``--persist-local-ip`` and ``--persist-remote-ip`` options respectively
15-
(see above).
13+
remote IP address/port based on ``--persist-tun``, ``--persist-local-ip``
14+
and ``--persist-remote-ip`` options respectively (see above).
1615

1716
This signal may also be internally generated by a timeout condition,
1817
governed by the ``--ping-restart`` option.

doc/man-sections/unsupported-options.rst

+3
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,6 @@ longer supported
4242

4343
--prng
4444
Removed in OpenVPN 2.6. We now always use the PRNG of the SSL library.
45+
46+
--persist-key
47+
Ignored since OpenVPN 2.7. Keys are now always persisted across restarts.

sample/sample-config-files/client.conf

-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ nobind
6262
;group openvpn
6363

6464
# Try to preserve some state across restarts.
65-
persist-key
6665
persist-tun
6766

6867
# If you are connecting through an

sample/sample-config-files/server.conf

+1-2
Original file line numberDiff line numberDiff line change
@@ -274,11 +274,10 @@ cipher AES-256-CBC
274274
;user openvpn
275275
;group openvpn
276276

277-
# The persist options will try to avoid
277+
# The persist option will try to avoid
278278
# accessing certain resources on restart
279279
# that may no longer be accessible because
280280
# of the privilege downgrade.
281-
persist-key
282281
persist-tun
283282

284283
# Output a short status file showing

sample/sample-windows/sample.ovpn

-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ secret key.txt
8989
; ping-restart 60
9090
; ping-timer-rem
9191
; persist-tun
92-
; persist-key
9392
; resolv-retry 86400
9493

9594
# keep-alive ping

src/openvpn/init.c

+2-10
Original file line numberDiff line numberDiff line change
@@ -3559,14 +3559,6 @@ do_option_warnings(struct context *c)
35593559
{
35603560
msg(M_WARN, "WARNING: you are using user/group/chroot/setcon without persist-tun -- this may cause restarts to fail");
35613561
}
3562-
if (!o->persist_key
3563-
#ifdef ENABLE_PKCS11
3564-
&& !o->pkcs11_id
3565-
#endif
3566-
)
3567-
{
3568-
msg(M_WARN, "WARNING: you are using user/group/chroot/setcon without persist-key -- this may cause restarts to fail");
3569-
}
35703562
}
35713563

35723564
if (o->chroot_dir && !(o->username && o->groupname))
@@ -3857,7 +3849,7 @@ static void
38573849
do_close_free_key_schedule(struct context *c, bool free_ssl_ctx)
38583850
{
38593851
/*
3860-
* always free the tls_auth/crypt key. If persist_key is true, the key will
3852+
* always free the tls_auth/crypt key. The key will
38613853
* be reloaded from memory (pre-cached)
38623854
*/
38633855
free_key_ctx(&c->c1.ks.tls_crypt_v2_server_key);
@@ -3866,7 +3858,7 @@ do_close_free_key_schedule(struct context *c, bool free_ssl_ctx)
38663858
buf_clear(&c->c1.ks.tls_crypt_v2_wkc);
38673859
free_buf(&c->c1.ks.tls_crypt_v2_wkc);
38683860

3869-
if (!(c->sig->signal_received == SIGUSR1 && c->options.persist_key))
3861+
if (!(c->sig->signal_received == SIGUSR1))
38703862
{
38713863
key_schedule_free(&c->c1.ks, free_ssl_ctx);
38723864
}

src/openvpn/openvpn.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848

4949
/*
5050
* Our global key schedules, packaged thusly
51-
* to facilitate --persist-key.
51+
* to facilitate key persistence.
5252
*/
5353

5454
struct key_schedule

src/openvpn/options.c

+10-13
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,6 @@ static const char usage_message[] =
273273
"--persist-tun : Keep tun/tap device open across SIGUSR1 or --ping-restart.\n"
274274
"--persist-remote-ip : Keep remote IP address across SIGUSR1 or --ping-restart.\n"
275275
"--persist-local-ip : Keep local IP address across SIGUSR1 or --ping-restart.\n"
276-
"--persist-key : Don't re-read key files across SIGUSR1 or --ping-restart.\n"
277276
#if PASSTOS_CAPABILITY
278277
"--passtos : TOS passthrough (applies to IPv4 only).\n"
279278
#endif
@@ -1857,7 +1856,6 @@ show_settings(const struct options *o)
18571856
SHOW_BOOL(persist_tun);
18581857
SHOW_BOOL(persist_local_ip);
18591858
SHOW_BOOL(persist_remote_ip);
1860-
SHOW_BOOL(persist_key);
18611859

18621860
#if PASSTOS_CAPABILITY
18631861
SHOW_BOOL(passtos);
@@ -3240,18 +3238,16 @@ options_postprocess_mutate_ce(struct options *o, struct connection_entry *ce)
32403238
ce->tls_crypt_v2_file_inline = o->tls_crypt_v2_file_inline;
32413239
}
32423240

3243-
/* Pre-cache tls-auth/crypt(-v2) key file if persist-key was specified and
3241+
/* Pre-cache tls-auth/crypt(-v2) key file if
32443242
* keys were not already embedded in the config file.
32453243
*/
3246-
if (o->persist_key)
3247-
{
3248-
connection_entry_preload_key(&ce->tls_auth_file,
3249-
&ce->tls_auth_file_inline, &o->gc);
3250-
connection_entry_preload_key(&ce->tls_crypt_file,
3251-
&ce->tls_crypt_file_inline, &o->gc);
3252-
connection_entry_preload_key(&ce->tls_crypt_v2_file,
3253-
&ce->tls_crypt_v2_file_inline, &o->gc);
3254-
}
3244+
connection_entry_preload_key(&ce->tls_auth_file,
3245+
&ce->tls_auth_file_inline, &o->gc);
3246+
connection_entry_preload_key(&ce->tls_crypt_file,
3247+
&ce->tls_crypt_file_inline, &o->gc);
3248+
connection_entry_preload_key(&ce->tls_crypt_v2_file,
3249+
&ce->tls_crypt_v2_file_inline, &o->gc);
3250+
32553251

32563252
if (!proto_is_udp(ce->proto) && ce->explicit_exit_notification)
32573253
{
@@ -6963,7 +6959,8 @@ add_option(struct options *options,
69636959
else if (streq(p[0], "persist-key") && !p[1])
69646960
{
69656961
VERIFY_PERMISSION(OPT_P_PERSIST);
6966-
options->persist_key = true;
6962+
msg(M_WARN, "DEPRECATED: --persist-key option ignored. "
6963+
"Keys are now always persisted across restarts. ");
69676964
}
69686965
else if (streq(p[0], "persist-local-ip") && !p[1])
69696966
{

src/openvpn/options.h

-1
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,6 @@ struct options
344344
bool persist_tun; /* Don't close/reopen TUN/TAP dev on SIGUSR1 or PING_RESTART */
345345
bool persist_local_ip; /* Don't re-resolve local address on SIGUSR1 or PING_RESTART */
346346
bool persist_remote_ip; /* Don't re-resolve remote address on SIGUSR1 or PING_RESTART */
347-
bool persist_key; /* Don't re-read key files on SIGUSR1 or PING_RESTART */
348347

349348
#if PASSTOS_CAPABILITY
350349
bool passtos;

0 commit comments

Comments
 (0)