]> git.ipfire.org Git - thirdparty/openvpn.git/log
thirdparty/openvpn.git
7 years agotun: ensure interface can be configured with IPv6 only
Antonio Quartulli [Mon, 18 Jun 2018 07:47:33 +0000 (15:47 +0800)] 
tun: ensure interface can be configured with IPv6 only

This change ensures that an interface is properly brought
up and down even when only IPv6 settings are configured/pushed.

At the same time, some code restyling took place to ensure the new
generic logic is easier to read. Both do_ifconfig() and close_tun()
(Linux only) functions have been rearranged by splitting the logic
into a v4 and a v6 specific part. Each part has then been moved
into an idependent helper that can be invoked as
needed.

This makes the code easier to read and more "symmetric" with
respect to the two address families.

Trac: #208
Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20180618074733.19773-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg17064.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agotun: get rid of tt->did_ifconfig member
Antonio Quartulli [Wed, 13 Jun 2018 12:28:24 +0000 (20:28 +0800)] 
tun: get rid of tt->did_ifconfig member

tt->did_ifconfig is currently only read by the Linux platform, but
it is currently uselessly set also by every other system.

The Linux platform does not actually even need this member and can
directly rely on tt->did_ifconfig_setup.

For the reasons above, remove the tt->did_ifconfig at all and use
tt->did_ifconfig_setup where needed (close_tun() on Linux).

Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20180613122824.4207-4-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg17046.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agotun: always pass a valid tt pointer
Antonio Quartulli [Wed, 13 Jun 2018 12:28:23 +0000 (20:28 +0800)] 
tun: always pass a valid tt pointer

This patch is a small "logic restyle" which basically moves the
check for "tt != NULL" outside of the various close_tun()
implementations and replaces it with an ASSERT.

This way the check is done only once and the function can rely
on the assumption that "tt" is always valid.

This change is mainly to improve the code style inside close_tun()
implementations by removing one level of indentation.

No functional change is present.

Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20180613122824.4207-3-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg17045.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agotun: ensure gc and argv are properly handled
Antonio Quartulli [Wed, 13 Jun 2018 12:28:22 +0000 (20:28 +0800)] 
tun: ensure gc and argv are properly handled

Everytime a argv object is initialized with argv_new(), it has
to be released with argv_reset() once not needed anymore.

Ensure this kind of objects are always properly released to avoid
memory leaks.

At the same time, remove those gc_arena objects that are initialized
but never used/released.

Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20180613122824.4207-2-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg17044.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agoAdd Interactive Service developer documentation
Simon Rozman [Thu, 19 Apr 2018 11:23:13 +0000 (13:23 +0200)] 
Add Interactive Service developer documentation

The OpenVPN Interactive Service documentation from
https://community.openvpn.net/openvpn/wiki/OpenVPNInteractiveService was
upgraded with a description of the client-service communication flow,
service registry configuration, and non-default instance installation.

Acked-by: Selva Nair <selva.nair@gmail.com>
Message-Id: <20180419112313.1013-1-simon@rozman.si>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg16794.html

Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agoReplace M_DEBUG with D_LOW as the former is too verbose
Selva Nair [Tue, 5 Jun 2018 20:06:10 +0000 (16:06 -0400)] 
Replace M_DEBUG with D_LOW as the former is too verbose

M_DEBUG only indicates the type of the message and will print even
at verb 0.  Use D_LOW which is M_DEBUG combined with verb = 4 and
a mute level.

Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1528229170-6175-1-git-send-email-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg16964.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agopool: convert pool 'type' to enum
Antonio Quartulli [Fri, 8 Jun 2018 05:20:12 +0000 (13:20 +0800)] 
pool: convert pool 'type' to enum

The pool 'type' member is actually an enumered type, therefore
declare it as 'enum' to improve static code analisys and
readability.

Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20180608052017.6696-4-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg17000.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agopool: restyle ipv4/ipv6 members to improve readability
Antonio Quartulli [Tue, 5 Jun 2018 09:04:18 +0000 (17:04 +0800)] 
pool: restyle ipv4/ipv6 members to improve readability

(This is only code refactoring)

IPv4 and IPv6 members are all part of the same flat hierarchy
in the pool data structure, without a proper name convention.

Create 2 sub-structures to properly separate IPv4 from IPv6
related members. This should make the structure more organized
and also slightly improve code readability.

Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20180605090421.9746-3-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg16944.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agoman: add security considerations to --compress section
Steffan Karger [Sun, 3 Jun 2018 10:11:56 +0000 (12:11 +0200)] 
man: add security considerations to --compress section

As Ahamed Nafeez reported to the OpenVPN security team, we did not
sufficiently inform our users about the risks of combining encryption
and compression.  This patch adds a "Security Considerations" paragraph
to the --compress section of the manpage to point the risks out to our
users.

Signed-off-by: Steffan Karger <steffan@karger.me>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1528020718-12721-1-git-send-email-steffan@karger.me>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg16919.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agoFix potential double-free() in Interactive Service (CVE-2018-9336)
Gert Doering [Sat, 14 Apr 2018 07:26:17 +0000 (09:26 +0200)] 
Fix potential double-free() in Interactive Service (CVE-2018-9336)

Malformed input data on the service pipe towards the OpenVPN interactive
service (normally used by the OpenVPN GUI to request openvpn instances
from the service) can result in a double free() in the error handling code.

This usually only leads to a process crash (DoS by an unprivileged local
account) but since it could possibly lead to memory corruption if
happening while multiple other threads are active at the same time,
CVE-2018-9336 has been assigned to acknowledge this risk.

Fix by ensuring that sud->directory is set to NULL in GetStartUpData()
for all error cases (thus not being free()ed in FreeStartupData()).

Rewrite control flow to use explicit error label for error exit.

Discovered and reported by Jacob Baines <jbaines@tenable.com>.

CVE: 2018-9336

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Selva Nair <selva.nair@gmail.com>
Message-Id: <20180414072617.25075-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/search?l=mid&q=20180414072617.25075-1-gert@greenie.muc.de

Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agoAdd negotiated cipher to status file format 2 and 3
Gert van Dijk [Sat, 11 Nov 2017 16:11:22 +0000 (17:11 +0100)] 
Add negotiated cipher to status file format 2 and 3

With NCP turned off, this will still display the cipher used.

Trac: #814

Signed-off-by: Gert van Dijk <gert@gertvandijk.net>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20171111161122.30087-2-gert@gertvandijk.net>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg15817.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agomanpage: improve description of --status and --status-version
Gert van Dijk [Sat, 11 Nov 2017 16:11:21 +0000 (17:11 +0100)] 
manpage: improve description of --status and --status-version

Signed-off-by: Gert van Dijk <gert@gertvandijk.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20171111161122.30087-1-gert@gertvandijk.net>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg15818.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agoAvoid overflow in wakeup time computation
Selva Nair [Tue, 6 Mar 2018 06:09:28 +0000 (01:09 -0500)] 
Avoid overflow in wakeup time computation

Time interval arithmetic can overflow especially when user
defined intervals are involved. E.g., see Trac #922.

Avoid this by reordering the arithmetic operation in
event_timeout_trigger(). Also avoid unnecessary casting of time
variable to int.

Time until wakeup is now calculated like:

time_t wakeup = (last - now) + delay

Here delay is of type int, but is +ve by construction. Time backtrack
protection in OpenVPN ensures (last - now) <= 0. Then the above
expression cannot overflow (provided time_t is at least as large
as int).

A similar expression in interval.h is also changed.

(This patch grew out of patch 168 by Steffan Karger.)

Trac: #922

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Message-Id: <1520316568-8983-1-git-send-email-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg16634.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agoMove env helper functions into their own module/file
Steffan Karger [Fri, 8 Dec 2017 12:07:47 +0000 (13:07 +0100)] 
Move env helper functions into their own module/file

To avoid a dependency on misc.c - which is a dependency mess - in the
tls-crypt unit tests, split the env_set functionality out into it's own
file.

Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
Signed-off-by: Steffan Karger <steffan.karger@fox-it.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1512734870-17133-8-git-send-email-steffan.karger@fox-it.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg16066.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agoCheck for more data in control channel
Steffan Karger [Thu, 4 Jan 2018 12:07:50 +0000 (13:07 +0100)] 
Check for more data in control channel

If control channel packets arrive quickly after each other, or out of
order, there might be more data available than we can read in one
tls_process() call.  If that happened, and no further control channel
packet arrived (e.g. because the last two packets arrived out-of-order),
we would wait for 16 second ("coarse timer") before we would read the
remaining data.  To avoid that, always schedule ourself again if there
was control channel data, to check whether more data is available.

For mbedtls, we could implement a slightly more elegant "is there more
data?" function, instead of blindly rescheduling.  But I can't find a way
to implement that for OpenSSL, and the current solution is very simple and
still has quite low overhead.

Signed-off-by: Steffan Karger <steffan.karger@fox-it.com>
Acked-by: David Sommerseth <davids@openvpn.net>
Message-Id: <1515067670-13094-1-git-send-email-steffan.karger@fox-it.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg16151.html
Signed-off-by: David Sommerseth <davids@openvpn.net>
7 years agoManagement: warn about password only when the option is in use
Selva Nair [Mon, 5 Mar 2018 15:28:00 +0000 (10:28 -0500)] 
Management: warn about password only when the option is in use

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1520263680-1260-1-git-send-email-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg16631.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agoMake return code external tls key match docs
Joost Rijneveld [Wed, 28 Feb 2018 13:52:40 +0000 (14:52 +0100)] 
Make return code external tls key match docs

In tls_ctx_use_external_private_key, the return codes were inverted
compared to what is documented in ssl_backend.h (and what can
reasonably be expected). Internally the return code is never checked,
so this did not directly result in any change of behavior.
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20180228135240.22945-1-joost@joostrijneveld.nl>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg16577.html

Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agoDelete the IPv6 route to the "connected" network on tun close
Selva Nair [Thu, 1 Mar 2018 20:34:44 +0000 (15:34 -0500)] 
Delete the IPv6 route to the "connected" network on tun close

This was missing on Windows when interactive service is in use.

v3: Mar 1, 2017: avoid code repetition and rebase to master

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1519936484-26102-1-git-send-email-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg16598.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agomanagement: Warn if TCP port is used without password
David Sommerseth [Wed, 28 Feb 2018 13:19:18 +0000 (14:19 +0100)] 
management: Warn if TCP port is used without password

It is not recommended to use --management on a TCP port without also
adding a password authentication, as this can easily be abused by other
users or processes being able to connect to the managmement interface.

Thus issue a warning that this configuration is strongly discouraged.

Signed-off-by: David Sommerseth <davids@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20180228131918.12954-3-davids@openvpn.net>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg16574.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agoSupport EC certificates with cryptoapicert
Selva Nair [Sun, 25 Feb 2018 05:02:15 +0000 (00:02 -0500)] 
Support EC certificates with cryptoapicert

Requires openssl 1.1.0 or higher

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Message-Id: <1519534935-16053-1-git-send-email-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg16553.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agoman: Reword --management to prefer unix sockets over TCP
David Sommerseth [Wed, 28 Feb 2018 13:19:17 +0000 (14:19 +0100)] 
man: Reword --management to prefer unix sockets over TCP

It is more secure to use unix sockets instead of TCP ports for the
management interface, so reword it and provide some details why TCP is
not recommended.

Also re-arranged this section to be somewhat easier to read and clearer
on a few related details.

Signed-off-by: David Sommerseth <davids@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20180228131918.12954-2-davids@openvpn.net>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg16573.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agoman: Add .TQ groff support macro
David Sommerseth [Wed, 28 Feb 2018 13:19:16 +0000 (14:19 +0100)] 
man: Add .TQ groff support macro

This introduces the .TQ groff macro.  Even though this can be found
in newer groff versions, not all platforms we support carries this one.

This macro makes it possible to have mulitple lines of options as
headers before describing all of these options in the same segment.

Signed-off-by: David Sommerseth <davids@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20180228131918.12954-1-davids@openvpn.net>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg16575.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agoWarn if tls-version-max < tls-version-min
Steffan Karger [Sat, 24 Feb 2018 17:04:49 +0000 (18:04 +0100)] 
Warn if tls-version-max < tls-version-min

This adds warnings for when a user or our code tries to set a maximum
TLS version that's smaller then the current configured minimum TLS
version.

(And fixes some related whitespace now I touch it anyway.)

Signed-off-by: Steffan Karger <steffan@karger.me>
Acked-by: Selva Nair <selva.nair@gmail.com>
Message-Id: <20180224170449.25194-1-steffan@karger.me>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg16545.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agombedtls: don't use API deprecated in mbed 2.7
Steffan Karger [Wed, 7 Feb 2018 12:22:46 +0000 (13:22 +0100)] 
mbedtls: don't use API deprecated in mbed 2.7

The void-returning mbedtls_sha256() was deprecated in mbed TLS 2.7.
Use our own md_full() abstraction instead.

(The new function can theoretically fail, but only in case of highly
unlikely digest function failures.  The personalisation on random using
the certificate is a best-effort measure, so we simply log a warning and
skip the personalisation if such highly unlikely errors occur.)

Signed-off-by: Steffan Karger <steffan.karger@fox-it.com>
Acked-by: Antonio Quartulli <a@unstable.cc>
Message-Id: <1518006166-14285-1-git-send-email-steffan.karger@fox-it.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg16445.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agoMove setting private key to a function in prep for EC support
Selva Nair [Fri, 23 Feb 2018 03:03:19 +0000 (22:03 -0500)] 
Move setting private key to a function in prep for EC support

- Also add reference counting to CAPI_DATA (application data):

  When the application data is assigned to the private key
  we free it in the key's finish method. Proper error handling
  requires to keep track of whether data is assigned to the
  key or not before an error occurs. For this purpose, add a
  reference count to CAPI_DATA struct and increment it when it is
  assigned to the key or its method.

  CAPI_DATA_free now frees the data only if ref_count <= 0

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Message-Id: <1519354999-18496-1-git-send-email-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg16536.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agoFix removal of on-link prefix on windows with netsh
Gert Doering [Tue, 20 Feb 2018 16:00:16 +0000 (17:00 +0100)] 
Fix removal of on-link prefix on windows with netsh

When adding / removing IPv6 routes, the host bits need to be zeroed or
netsh.exe will refuse to handle the route.

Commit a24dd2e31 changed the way this is done, breaking removal of
the on-link IPv6 prefix for windows + netsh.exe.

Fix by adding explicitly calling route_ipv6_clear_host_bits() from
delete_route_connected_v6_net().

Trac: #1003

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Selva Nair <selva.nair@gmail.com>
Message-Id: <20180220160016.69786-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg16508.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agoFix format spec errors in Windows builds
Selva Nair [Thu, 22 Feb 2018 04:54:55 +0000 (23:54 -0500)] 
Fix format spec errors in Windows builds

- "%ll" is not supported by Windows run time, so use PRIi64
   and cast the variable to (int64_t) in output statements
   (as in commit 9ba36639abcac4367c8227d2dd87b18fb56267c4)

- Fix an instance of wchar_t * printed using %s -- should be %ls.

- Cast variables to int or unsigned int to match the output
  format spec when necessary.

- In route.c correct format of adapter_index (should be %lu) in a few
  places and remove some unnecessary casts to (unsigned int). Not
  all such instances are changed, only those related to adapter_index
  (for consistency) or close-by contexts are edited.

Most of these errors are seen in current Windows cross-compile,
but a few are triggered only if some DEBUG options are enabled.
Some are not in Windows specific paths. But for consistency, all uses
of %llu/%lld are removed. As these only affect log output, there are
no potential side effects.

Replacing long long by int64_t also has the advantage of avoiding
size ambiguity as long long is not guaranteed to be 64 bytes.

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Message-Id: <1519275295-29121-1-git-send-email-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg16522.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agomanpage: fix simple typ0
Antonio Quartulli [Fri, 12 Jan 2018 09:14:14 +0000 (17:14 +0800)] 
manpage: fix simple typ0

Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20180112091414.16271-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg16198.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agoGet rid of ax_check_compile_flag.m4
Steffan Karger [Tue, 20 Feb 2018 20:25:08 +0000 (21:25 +0100)] 
Get rid of ax_check_compile_flag.m4

The macro was too new for some of the platforms we still support.  In
particular, centos/rhel 6 and opensolaris 10.  To work around that, we
introduce our own simpler and more tailored ACL_CHECK_ADD_COMPILE_FLAGS
macro, that not only checks but also sets the flags in CFLAGS if it is
accepted.  Since this doesn't use new-and-shine autoconf features, it
should also work on the legacy platforms.

Signed-off-by: Steffan Karger <steffan@karger.me>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20180220202508.16201-1-steffan@karger.me>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg16515.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agoAdapt to RegGetValue brokenness in Windows 7
Selva Nair [Wed, 21 Feb 2018 05:38:30 +0000 (00:38 -0500)] 
Adapt to RegGetValue brokenness in Windows 7

- RegGetValue with flags = RRF_RT_REG_SZ|RRF_RT_REG_EXPAND_SZ
  fails in Windows 7 with an "invalid parameter" error.
  Fix by using RRF_RT_REG_SZ alone.

Note: This is not a regression as in no released version did the
service support expandable strings (ones with embedded %FOO%) in
the registry. However, the GUI does expand such strings. The two
can be made consistent by explicitly expanding the strings -- that
is left for a future patch.

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1519191510-3826-1-git-send-email-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg16513.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agoDisable external ec key support when building with libressl
Selva Nair [Wed, 21 Feb 2018 16:46:02 +0000 (11:46 -0500)] 
Disable external ec key support when building with libressl

- This codepath uses some openssl-1.1 specific API and is enabled only
  for openssl 1.1 and higher versions. But, due to incompatible
  version numbering in libressl, it gets wrongly enabled with libressl
  versions that do not support the reqired API. As an easy workaround
  disable the feature when LIBRESSL_VERSION_NUMBER is defined.

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1519231562-5641-1-git-send-email-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg16510.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agoMove code to free cd to a function CAPI_DATA_free()
Selva Nair [Fri, 26 Jan 2018 16:05:32 +0000 (11:05 -0500)] 
Move code to free cd to a function CAPI_DATA_free()

- Avoids code-repetition especially so when support
  for more key types are added.

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1516982732-24145-1-git-send-email-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg16383.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agoreliable: remove reliable_unique_retry()
Steffan Karger [Wed, 3 Jan 2018 09:40:48 +0000 (10:40 +0100)] 
reliable: remove reliable_unique_retry()

This function has been in the code since 2005, and enabled since 2010, but
it's not clear why we'd want this behaviour.

Running some simple tests, where I simulate an server->client link of
1mbit with 30ms delay and 1% packet loss, and a client->server link of
200kbit, 200ms delay, I get the following connection setup times over
100 runs when pushing ~100kb of options (e.g. a lot of routes):

With reliable_unique_retry:    Mean: 14.9 s, Std dev: 9.1 s
Without reliable_unique_retry: Mean: 11.8 s, Std dev: 5.8 s

For more standard push sizes (~1kb), the effect is of course smaller:

With reliable_unique_retry:    Mean: 2.7 s, Std dev: 0.6 s
Without reliable_unique_retry: Mean: 2.6 s, Std dev: 0.7 s

This shows that this mechanism hurts performance under packet loss
conditions.  (Without packet loss, there are no retransmissions and this
has no influence, of course.)  Querying the openvpn collective memory
(read: James, David and Gert) did not yield any arguments to keep it.
James even mentioned that OpenVPN 3 doesn't include this mechanism.

So, improve our connection setup performance by removing some code :)

Signed-off-by: Steffan Karger <steffan.karger@fox-it.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1514972448-7010-1-git-send-email-steffan.karger@fox-it.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg16146.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agotravis-ci: modify openssl build script to support openssl-1.1.0
Ilya Shipitsin [Mon, 15 Jan 2018 08:05:55 +0000 (13:05 +0500)] 
travis-ci: modify openssl build script to support openssl-1.1.0

get rid of no-multilib, as it is not supported on openssl-1.1.0

Signed-off-by: Ilya Shipitsin <chipitsine@gmail.com>
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Message-Id: <20180115080555.18202-1-chipitsine@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg16229.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agoUse lowest metric interface when multiple interfaces match a route
Selva Nair [Wed, 24 Jan 2018 17:31:45 +0000 (12:31 -0500)] 
Use lowest metric interface when multiple interfaces match a route

Currently a route addition using IPAPI or service is skipped if the
route gateway is reachable by multiple interfaces. This changes that
to use the interface with lowest metric. Implemented by

(i)  Do not over-write the return value with TUN_ADAPTER_INDEX_INVALID in
     windows_route_find_if_index() if multiple interfaces match a route.
(ii) Select the interface with lowest metric in adapter_index_of_ip()
     instead of the first one found when multiple interfaces match.

Reported by Jan Just Keijser <janjust@nikhef.nl>

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Tested-by: Jan Just Keijser <janjust@nikhef.nl>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1516815105-17882-1-git-send-email-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg16347.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agoMake most registry values optional
Selva Nair [Sat, 18 Nov 2017 17:40:58 +0000 (12:40 -0500)] 
Make most registry values optional

Not all installations need registry values such as log_dir and
config_dir especially if automatic service is not in use.
This patch provides reasonable defaults for registry values.

- Read the default value of HKLM\Software\PACKAGE_NAME to get the
  install path and construct defaults for exe_path, config_dir,
  log_dir from it. Use "ovpn", "0", NORMAL_PRIORITY as the defaults
  for config file extension, log-append flag and process priority.

The only remaining required registry entry is the root key (usually
HKLM\Software\OpenVPN) whose default value should be set to the
installation path.

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1511026858-23281-2-git-send-email-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg15892.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agoEnsure strings read from registry are null-terminated
Selva Nair [Sat, 18 Nov 2017 17:40:57 +0000 (12:40 -0500)] 
Ensure strings read from registry are null-terminated

- Strings stored in registry are not guaranteed to be null-terminated.
  So, use RegGetValue() instead of RegQueryValueEx() as the former
  adds null termination to the returned string if missing.
  (Needs Windows Vista+)

- While at it also add a default value parameter to GetRegString()
  to process optional registry values (such as ovpn_admin_group)
  without causing an otherwise confusing error logged to the
  eventlog[*].

[*] see Trac: #892

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1511026858-23281-1-git-send-email-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg15893.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agoAllow external EC key through --management-external-key
Selva Nair [Thu, 25 Jan 2018 19:45:13 +0000 (14:45 -0500)] 
Allow external EC key through --management-external-key

- This automatically supports EC certificates through
  --management-external-cert
- EC signature request from management is prompted by
  >PK_SIGN if the client supports it (or >RSA_SIGN)
  Response should be of the form 'pk-sig' (or rsa-sig
  by older clients) followed by DER encoded signature
  as base64 terminated by 'END' on a new line.

v3: This is v2 adapted to the client_version capability
Requires pacthes 1 and 2 of the series 147:
https://patchwork.openvpn.net/project/openvpn2/list/?series=147

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <1516909513-31683-1-git-send-email-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg16365.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agoshow the right string for key-direction
Arne Schwabe [Wed, 31 Jan 2018 09:53:00 +0000 (10:53 +0100)] 
show the right string for key-direction

V2: print also a nice string if direction is not set
V3: really include V2 changes
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Message-Id: <1517392380-21597-1-git-send-email-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg16415.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agoEnable stricter compiler warnings by default
Steffan Karger [Thu, 1 Feb 2018 15:45:21 +0000 (16:45 +0100)] 
Enable stricter compiler warnings by default

This by default enables the compiler warnings one could previously
enable using the --enable-strict configure option.  I think it is
okay to do so now, because we've taken care of many warnings in the
more standard builds.  (Most of those were totally harmless, but they
prevented us from spotting new more serious mistakes.)

The --enable-strict flag now enables two extra warning flags that I
think can be useful:

-Wsign-compare warns when the compiler promotes a signed type to
unsigned before comparing, which can lead to unexpected behaviour.

-Wuninitialized adds extra warnings about usage of uninitialized variables
or struct elements.

Signed-off-by: Steffan Karger <steffan@karger.me>
Acked-by: Selva Nair <selva.nair@gmail.com>
Message-Id: <20180201154521.7642-1-steffan@karger.me>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg16426.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agoLog pre-handshake packet drops using D_MULTI_DROPPED
Steffan Karger [Sun, 11 Feb 2018 10:19:29 +0000 (11:19 +0100)] 
Log pre-handshake packet drops using D_MULTI_DROPPED

We have a debug level packets dropped by the TLS layer - use that for this
packet drop too.  This changes this message from 'verb 3' to 'verb 4'
(which should result in less user reports about this almost always
harmless warning).

Signed-off-by: Steffan Karger <steffan@karger.me>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20180211101929.4535-1-steffan@karger.me>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg16477.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agoTreat dhcp-option DNS6 and DNS identical
Arne Schwabe [Wed, 31 Jan 2018 09:41:02 +0000 (10:41 +0100)] 
Treat dhcp-option DNS6 and DNS identical

OpenVPN3 accepts both IPv4 and IPv6 with option-dhcp DNS but throws
an error for option-dhcp DNS6.

This patch makes OpenVPN2 accept IPv4/IPv6 for both DNS and DNS6

V2: Put IPv6 parsing logic into own function similar as for for IPv4 DNS
V3: more documentation / help message adjustments

Acked-by: Selva Nair <selva.nair@gmail.com>
Message-Id: <1517391662-21325-1-git-send-email-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg16413.html

Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agoUpdate copyright to include 2018 plus company name change
David Sommerseth [Wed, 31 Jan 2018 14:03:14 +0000 (15:03 +0100)] 
Update copyright to include 2018 plus company name change

The autumn of 2017, OpenVPN Technologies, Inc changed name to just
OpenVPN Inc.  Otherwise, extend the copyright to cover 2018 as well.

With the exception of the company name change, all changes have been
performed by the dev-tools/update-copyright.sh script.

Signed-off-by: David Sommerseth <davids@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20180131140314.11103-1-davids@openvpn.net>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg16418.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agoPrompt for signature using '>PK_SIGN' if the client supports it
Selva Nair [Thu, 25 Jan 2018 19:41:01 +0000 (14:41 -0500)] 
Prompt for signature using '>PK_SIGN' if the client supports it

- Increase the management version from 1 to 2
- If the client announces support for management version > 1
  prompt for signature using >PK_SIGN to which the client
  responds using 'pk-sig'
  Older (current) clients will be continued to be prompted
  by '>RSA_SIGN' and can respond using 'rsa-sig'
- Remove an unused rsa_sig buffer-list variable

This facilitates a transparent transition to PK_SIG and future deprecation
of RSA_SIGN

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <1516909261-31623-2-git-send-email-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg16364.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agoAdd management client version
Selva Nair [Thu, 25 Jan 2018 19:41:00 +0000 (14:41 -0500)] 
Add management client version

- "version" command from client to management can now set
  the version of management interface supported by the client
  by specifying an optional integer parameter.

  If no parameter is specified the version of OpenVPN
  and its management interface is returned (current behaviour).

  The client version defaults to 1 which is the current version of
  the Management Interface.

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <1516909261-31623-1-git-send-email-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg16363.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agoRefactor get_interface_metric to return metric and auto flag separately
Selva Nair [Wed, 6 Dec 2017 04:28:41 +0000 (23:28 -0500)] 
Refactor get_interface_metric to return metric and auto flag separately

- Instead of returning metric = 0 when automatic metric is in use
  return the actual metric and flag automatic metric through a
  parameter. This makes the function reusable elsewhere.

- Ensure return value can be correctly cast to int and return -1 on
  error.

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Simon Rozman <simon@rozman.si>
Message-Id: <1512534521-14760-1-git-send-email-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg16039.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agoRefactor ssl_openssl.c in prep for external EC key support
Selva Nair [Sun, 14 Jan 2018 19:44:31 +0000 (14:44 -0500)] 
Refactor ssl_openssl.c in prep for external EC key support

- Move setting of key method callbacks into a function

No change in functionality.

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <1515959073-10376-2-git-send-email-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg16227.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agoPlug memory leak if push is interrupted
Steffan Karger [Wed, 17 Jan 2018 13:16:24 +0000 (14:16 +0100)] 
Plug memory leak if push is interrupted

If a push is interrupted due to a timeout, c->c2.pulled_options_state is
never freed.  Fix that by always cleaning up any remaining pulled
options state when we close a connection.

This changes the mbedtls implementation of md_ctx_cleanup to actually
clean up the context, which was not needed earlier.

Signed-off-by: Steffan Karger <steffan.karger@fox-it.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1516194984-1540-1-git-send-email-steffan.karger@fox-it.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg16265.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agoDocument missing OpenVPN states
Simon Rozman [Mon, 15 Jan 2018 11:47:28 +0000 (12:47 +0100)] 
Document missing OpenVPN states

Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20180115114728.13672-1-simon@rozman.si>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg16232.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agoTLS v1.2 support for cryptoapicert -- RSA only
Selva Nair [Sat, 20 Jan 2018 04:52:54 +0000 (23:52 -0500)] 
TLS v1.2 support for cryptoapicert -- RSA only

- If an NCRYPT handle for the private key can be obtained, use
  NCryptSignHash from the Cryptography NG API to sign the hash.

  This should work for all keys in the Windows certifiate stores
  but may fail for keys in a legacy token, for example. In such
  cases, we disable TLS v1.2 and fall back to the current
  behaviour. A warning is logged unless TLS version is already
  restricted to <= 1.1

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Message-Id: <1516423974-22159-1-git-send-email-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg16288.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agotls_ctx_set_tls_versions: move verify_flags to where it is used
Steffan Karger [Sun, 26 Nov 2017 14:15:55 +0000 (15:15 +0100)] 
tls_ctx_set_tls_versions: move verify_flags to where it is used

Minor cleanup of this function now that we are allowed to write C99: move
(and rename) flags to the code where it's actually used to improve
readability.

(I originally did this as part of the tls-version-{min,max} patch for
openssl 1.1, but that made the diff hard to read.)

Signed-off-by: Steffan Karger <steffan@karger.me>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20171126141555.25930-3-steffan@karger.me>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg15931.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agoAdd SSL_CTX_get_max_proto_version() not in openssl 1.0
Selva Nair [Sat, 20 Jan 2018 04:47:27 +0000 (23:47 -0500)] 
Add SSL_CTX_get_max_proto_version() not in openssl 1.0

- No change in functionality. This is used in a subsequent
  patch for extending TLS1.2 support with cryptoapicert

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Message-Id: <1516423647-21932-1-git-send-email-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg16287.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agoAdd support for TLS 1.3 in --tls-version-{min, max}
Steffan Karger [Sun, 26 Nov 2017 14:15:54 +0000 (15:15 +0100)] 
Add support for TLS 1.3 in --tls-version-{min, max}

Tested with the current openssl master branch for TLS 1.3 support.

mbed TLS has no public builds with TLS 1.3 support yet, so nothing to do
there right now.

Signed-off-by: Steffan Karger <steffan@karger.me>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20171126141555.25930-2-steffan@karger.me>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg15932.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agoFix --tls-version-min and --tls-version-max for OpenSSL 1.1+
Steffan Karger [Fri, 19 Jan 2018 21:27:21 +0000 (22:27 +0100)] 
Fix --tls-version-min and --tls-version-max for OpenSSL 1.1+

As described in <80e6b449-c536-dc87-7215-3693872bce5a@birkenwald.de> on
the openvpn-devel mailing list, --tls-version-min no longer works with
OpenSSL 1.1.  Kurt Roeckx posted in a debian bug report:

"This is marked as important because if you switch to openssl 1.1.0
the defaults minimum version in Debian is currently TLS 1.2 and
you can't override it with the options that you're currently using
(and are deprecated)."

This patch is loosely based on the original patch by Kurt, but solves the
issue by adding functions to openssl-compat.h, like we also did for all
other openssl 1.1. breakage.  This results in not having to add more ifdefs
in ssl_openssl.c and thus cleaner code.

Signed-off-by: Steffan Karger <steffan@karger.me>
Acked-by: Selva Nair <selva.nair@gmail.com>
Message-Id: <20180119212721.25177-1-steffan@karger.me>
URL: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=873302
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg16284.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agoReplace buffer backed strings for management_android_control with simple stack variables
Arne Schwabe [Wed, 17 Jan 2018 10:38:36 +0000 (11:38 +0100)] 
Replace buffer backed strings for management_android_control with simple stack variables

This simplifies the code a bit and also silences compiler warnings about
uint8_t pointers passed to char pointers without cast

Patch V2: Use openvpn_snprintf instead snprintf
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1516185516-28125-1-git-send-email-arne@rfc2549.org>
URL: https://www.mail-archive.com/search?l=mid&q=1516185516-28125-1-git-send-email-arne@rfc2549.org

Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agoBring cryptoapi.c upto speed with openssl 1.1
Selva Nair [Sun, 14 Jan 2018 19:04:22 +0000 (14:04 -0500)] 
Bring cryptoapi.c upto speed with openssl 1.1

- Replace direct access to internals of openssl structs
  by corresponding methods.

v2: Remove the call to EVP_PKEY_id() as its slated for removal
    from the compat layer (see also review by Stefan)

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Message-Id: <1515956662-30572-1-git-send-email-selva.nair@gmail.com>
URL: https://www.mail-archive.com/search?l=mid&q=1515956662-30572-1-git-send-email-selva.nair@gmail.com
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agoUse RSA_meth_free instead of free
Selva Nair [Sat, 13 Jan 2018 23:00:46 +0000 (18:00 -0500)] 
Use RSA_meth_free instead of free

- RSA_meth_new allocates memory for the name string
  and must be released using RSA_meth_free

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Emmanuel Deloget <logout@free.fr>
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Message-Id: <1515884446-27152-1-git-send-email-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg16207.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agoOpenSSL: check EVP_PKEY key types before returning the pkey
Emmanuel Deloget [Fri, 12 Jan 2018 16:48:24 +0000 (17:48 +0100)] 
OpenSSL: check EVP_PKEY key types before returning the pkey

The internal EVP_PKEY::pkey member is an union thus we need to check for
the real key type before we can return the corresponding RSA, DSA or EC
public key.

Reported-by: Selva Nair <selva.nair@gmail.com>
Signed-off-by: Emmanuel Deloget <logout@free.fr>
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Message-Id: <e8333f0b838670e558a9fe292cea8988484cd77f.1515775195.git.logout@free.fr>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg16202.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agossl_openssl: fix compiler warning by removing getbio() wrapper
Steffan Karger [Thu, 14 Dec 2017 10:21:37 +0000 (11:21 +0100)] 
ssl_openssl: fix compiler warning by removing getbio() wrapper

An API change in openssl 1.1 made the BIO_METHOD * returned by BIO_f_ssl()
and BIO_s_mem() const, as well as the BIO_METHOD * argment of BIO_new()
const.  This meant that our getbio() function would either have an API
inconsistent with 1.0 or 1.1.

The wrapper was basically an ASSERT, so fix this by replacing the wrapper
with an ASSERT.

Signed-off-by: Steffan Karger <steffan@karger.me>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <1513246897-28171-1-git-send-email-steffan@karger.me>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg16083.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agoFix types around buffer_list_push(_data)
Steffan Karger [Wed, 10 Jan 2018 08:34:19 +0000 (09:34 +0100)] 
Fix types around buffer_list_push(_data)

In C, strings are char pointers, not unsigned char pointers.  And
arbitrary data is represented by a void pointer.  Change buffer_list_push
and buffer_list_push_data to follow these rules, and remove any now
unneeded casts.

Signed-off-by: Steffan Karger <steffan.karger@fox-it.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1515573259-20968-1-git-send-email-steffan.karger@fox-it.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg16186.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agobuffer_list_aggregate_separator(): prevent 0-byte malloc
Steffan Karger [Fri, 29 Dec 2017 09:54:00 +0000 (10:54 +0100)] 
buffer_list_aggregate_separator(): prevent 0-byte malloc

As pointed out in finding OVPN-05 of the cryptograpy engineering audit
(funded by Private Internet Access), buffer_list_aggregate_separator()
could perform a 0-byte malloc when called with a list of 0-length buffers
and a "" separator.  If other could would later try to access that buffer
memory, this would result in undefined behaviour.  To prevent this, always
malloc() 1 byte.

To simplify as we go, use alloc_buf() to allocate the buffer.  This has
the additional benefit that the actual buffer data (not the contents) is
zero-terminated, because alloc_buf() calls calloc() and we have 1 extra
byte of data.

Signed-off-by: Steffan Karger <steffan.karger@fox-it.com>
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Message-Id: <1514541240-19536-1-git-send-email-steffan.karger@fox-it.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg16106.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agobuffer_list_aggregate_separator(): don't exceed max_len
Steffan Karger [Fri, 29 Dec 2017 09:53:11 +0000 (10:53 +0100)] 
buffer_list_aggregate_separator(): don't exceed max_len

buffer_list_aggregate_separator() would merge buffer_list entries until it
had exceeded the provided max_len, instead of stopping *before* exceeding
the max value.

Signed-off-by: Steffan Karger <steffan.karger@fox-it.com>
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Message-Id: <1514541191-19471-1-git-send-email-steffan.karger@fox-it.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg16104.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agobuffer_list_aggregate_separator(): update list size after aggregating
Steffan Karger [Fri, 29 Dec 2017 09:52:24 +0000 (10:52 +0100)] 
buffer_list_aggregate_separator(): update list size after aggregating

After aggregating a buffer_list, the size should be adjusted accordingly.

Signed-off-by: Steffan Karger <steffan.karger@fox-it.com>
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Message-Id: <1514541144-19407-1-git-send-email-steffan.karger@fox-it.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg16103.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agoFix typo in error message: "optione" -> "option"
Bertrand Bonnefoy-Claudet [Tue, 2 Jan 2018 14:09:38 +0000 (15:09 +0100)] 
Fix typo in error message: "optione" -> "option"

Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20180102140938.16467-1-bertrandbc@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg16131.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agoDon't throw fatal errors from verify_cert_export_cert()
Steffan Karger [Tue, 2 Jan 2018 22:52:51 +0000 (23:52 +0100)] 
Don't throw fatal errors from verify_cert_export_cert()

As with create_temp_file(), this function is called on client connects
and should not cause fatal errors when I/O (possibly temporarily) fails.
Fix this and the openssl backend implementation of x509_write_pem() to
no longer throw fatal errors.

The callers of this function are already fixed in the commit that does
the same for create_temp_file().

Signed-off-by: Steffan Karger <steffan.karger@fox-it.com>
Acked-by: Selva Nair <selva.nair@gmail.com>
Message-Id: <1514933571-4592-1-git-send-email-steffan.karger@fox-it.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg16136.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agoReturn NULL if GetAdaptersInfo fails
Selva Nair [Wed, 3 Jan 2018 04:02:03 +0000 (23:02 -0500)] 
Return NULL if GetAdaptersInfo fails

- Currently a pointer to potentially uninitialized IP_ADAPTER_INFO
  struct is returned on error causing ill-defined behaviour.

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Acked-by: Simon Rozman <simon@rozman.si>
Message-Id: <1514952123-26616-1-git-send-email-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg16139.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agotravis: use clang's -fsanitize=address to catch more bugs
Steffan Karger [Fri, 29 Dec 2017 09:47:37 +0000 (10:47 +0100)] 
travis: use clang's -fsanitize=address to catch more bugs

The clang address sanitizer is able to catch quite a number of
memory-related bugs, such add memory leaks and buffer under/overruns.
So, enable the address sanitizer for one openssl and one mbedtls build.

This would have caught the buffer list unittest memory leak that
<1512724338-22197-1-git-send-email-steffan@karger.me> wants to fix.

Signed-off-by: Steffan Karger <steffan.karger@fox-it.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1514540857-19290-1-git-send-email-steffan.karger@fox-it.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg16102.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agoFix memory leak in buffer unit tests
Steffan Karger [Fri, 8 Dec 2017 09:12:18 +0000 (10:12 +0100)] 
Fix memory leak in buffer unit tests

buffer_list_push_data does not take ownership of the memory, so just feed
it stack data to plug the leak.

Signed-off-by: Steffan Karger <steffan@karger.me>
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Message-Id: <1512724338-22197-1-git-send-email-steffan@karger.me>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg16055.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agotravis-ci: add brew cache, remove ccache
Ilya Shipitsin [Thu, 4 Jan 2018 19:37:10 +0000 (00:37 +0500)] 
travis-ci: add brew cache, remove ccache

1-2 minutes speedup osx builds by using brew cache.
Also, ccache was removed for a while (builds fail
after travis-ci upgraded clang to version 5.0.0)
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Message-Id: <20180104193710.23778-1-chipitsine@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg16154.html

Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agombedtls: fix typ0 in comment
Antonio Quartulli [Tue, 5 Dec 2017 08:57:11 +0000 (16:57 +0800)] 
mbedtls: fix typ0 in comment

the function used to set the verify callback in mbedTLS is
actually called mbedtls_ssl_conf_verify() and it is invoked
in key_state_ssl_init().

Fix comment accordingly.

Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Message-Id: <20171205085711.25075-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg16026.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agoAllow learning iroutes with network made up of all 0s (only if netbits < 8)
Antonio Quartulli [Wed, 6 Dec 2017 15:43:56 +0000 (23:43 +0800)] 
Allow learning iroutes with network made up of all 0s (only if netbits < 8)

It is plausible for a user to be willing to add a route for a network
made up of all 0s via a VPN client (i.e. 0.0.0.0/1), therefore such
iroute should be supported.

As of now the option parsing code will accept such iroute, but
the learning routine will (silently) reject it after a sanity check.

Such check prevents routes with network made up of all 0s to be
learnt at all..

Change the sanity check so that it will reject iroutes to network
made up of 0s only when netbits is greater than 7.

The reason for choosing 7 is because anything within 0.0.0.0/8 is not
really routable among networks.

While at it, make the sanity check louder so that it can print the
reason why a route is being rejected.

Trac: #726
Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: David Sommerseth <davids@openvpn.net>
Message-Id: <20171206154356.30764-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg16044.html
Signed-off-by: David Sommerseth <davids@openvpn.net>
7 years agoreload HTTP proxy credentials when moving to the next connection profile
Antonio Quartulli [Mon, 4 Dec 2017 04:49:07 +0000 (12:49 +0800)] 
reload HTTP proxy credentials when moving to the next connection profile

The HTTP proxy credentials are stored in a static variable that is
possibly initialized before each connection attempt.

However, the variable is never "released" therefore get_user_pass()
refuses to overwrite its content and leaves it as it is.
Consequently, if the user config contains multiple connection profiles
with different http-proxy, each having its own credentials, only the
first user/pass couple is loaded and the others are all ignored.
This leads to connection failures because the proper credentials are
not associated with the right proxy server.

The root of the misbehaviour seems to be located in the fact that,
despite the argument force passed to get_user_pass_http() being true,
no action is taken to release the static object containing the
credentials.

Fix the misbehaviour by releasing the http-proxy credential object
when the reload is "forced".

Trac: #836
Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Steffan Karger <steffan@karger.me>
Tested-by: David Sommerseth <davids@openvpn.net>
Acked-by: David Sommerseth <davids@openvpn.net>
Message-Id: <20171204044907.32261-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg16007.html
Signed-off-by: David Sommerseth <davids@openvpn.net>
7 years agoRemove MD5SUM
Antonio Quartulli [Sat, 2 Dec 2017 13:45:40 +0000 (21:45 +0800)] 
Remove MD5SUM

Apparently the MS5SUM macro is not used anywhere.
Remove it.

Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Message-Id: <20171202134541.7688-6-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg15954.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agoRemove SSL_LIB_VER_STR
Antonio Quartulli [Sat, 2 Dec 2017 13:45:38 +0000 (21:45 +0800)] 
Remove SSL_LIB_VER_STR

SSL_LIB_VER_STR made sense only when ENABLE_CRYPTO also
existed. It can now be removed and thus simplify the code.

Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Message-Id: <20171202134541.7688-4-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg15951.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agoRemove ENABLE_PUSH_PEER_INFO
Antonio Quartulli [Sat, 2 Dec 2017 13:45:37 +0000 (21:45 +0800)] 
Remove ENABLE_PUSH_PEER_INFO

ENABLE_PUSH_PEER_INFO depended on ENABLE_CRYPTO that now does
not exist anymore.
Get rid of ENABLE_PUSH_PEER_INFO by assuming that it is always
enabled and simplify the code.

Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Message-Id: <20171202134541.7688-3-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg15953.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agoRemove option to disable crypto engine
Antonio Quartulli [Sun, 3 Dec 2017 12:49:52 +0000 (20:49 +0800)] 
Remove option to disable crypto engine

With this patch we remove the possibility to disable the crypto engine
(ENABLE_CRYPTO define) at configuration time.

[--disable-crypto has been removed from .travis.yml too]

Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Message-Id: <20171203124952.15220-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg15979.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agoRemove ENABLE_CRYPTO
Antonio Quartulli [Mon, 4 Dec 2017 01:01:10 +0000 (09:01 +0800)] 
Remove ENABLE_CRYPTO

The crypto engine cannot be disabled anymore, therefore get
rid of all the related ifdefs in the code.

This change makes the code simpler and reduces our the
number of config combinations we have to test after a new
change is applied.

Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Message-Id: <20171204010110.22091-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg16004.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agoopenvpnserv: Add support for multi-instances
Simon Rozman [Sun, 3 Dec 2017 21:16:54 +0000 (22:16 +0100)] 
openvpnserv: Add support for multi-instances

While openvpn.exe can run multiple concurrent processes, openvpnserv.exe
is usually only one single globally unique running process.

This patch extends openvpnserv.exe to support multiple service instances
in parallel allowing side-by-side OpenVPN installations.

Alternate instances must be installed as `SERVICE_WIN32_OWN_PROCESS`
(Type 0x10) and must use the newly introduced service command line
parameter:
-instance <name> <id>
<name> can be `automatic` or `interactive`.

- The service settings will be loaded from `HKLM\Software\OpenVPN<id>`
  registry key.

- The automatic service will use `openvpn<id>_exit_1` exit event.

- The interactive service will accept requests on
  `\\.\pipe\openvpn<id>\service` named pipe, and run IPC with
  openvpn.exe on `\\.\pipe\openvpn<id>\service_<pid>`.

This patch preserves backward compatibility, by defaulting to
`SERVICE_WIN32_SHARE_PROCESS` and `<empty string>` as service ID.

Acked-by: Selva Nair <selva.nair@gmail.com>
Message-Id: <20171203211654.1044-1-simon@rozman.si>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg16002.html

Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agoopenvpnserv: Review MSVC down-casting warnings
Simon Rozman [Sun, 3 Dec 2017 20:30:07 +0000 (21:30 +0100)] 
openvpnserv: Review MSVC down-casting warnings

Data size arithmetic was reviewed according to 64-bit MSVC complaints.

The warnings were addressed by migrating to size_t, rewriting the code,
or silencing the warnings by an explicit cast where appropriate.
Acked-by: Selva Nair <selva.nair@gmail.com>
Message-Id: <20171203203007.6628-1-simon@rozman.si>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg16001.html

Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agoUse P_DATA_V2 for server->client packets too
Steffan Karger [Fri, 24 Nov 2017 13:58:23 +0000 (14:58 +0100)] 
Use P_DATA_V2 for server->client packets too

P_DATA_V2 introduced the peer-id.  This allows clients to float, but as a
side-effect 32-bit aligns the encrypted data.  That alignment improves
performance particularly on cheaper/older CPUs.  So although servers don't
actually have a peer-id, still use the V2 packet format (with a zero-id)
for server->client traffic too.

Signed-off-by: Steffan Karger <steffan@karger.me>
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1511531903-19349-1-git-send-email-steffan.karger@fox-it.com>
URL: https://www.mail-archive.com/search?l=mid&q=1511531903-19349-1-git-send-email-steffan.karger@fox-it.com
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agocreate_temp_file/gen_path: prevent memory leak if gc == NULL
Steffan Karger [Wed, 1 Nov 2017 22:03:42 +0000 (23:03 +0100)] 
create_temp_file/gen_path: prevent memory leak if gc == NULL

If gc == NULL, the data allocated in the alloc_gc_buf() call in
create_temp_file or the string_mod_const call in gen_path would never
be free'd.

These functions are currently never called that way, but let's prevent
future problems.

While touching create_temp_file, also remove the counter variable, which is
never read, simplify the do-while to a while loop, and truncate the prefix
(if needed) to preserve the random and extension of the created filename.

Signed-off-by: Steffan Karger <steffan@karger.me>
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Message-Id: <20171101220342.14648-5-steffan@karger.me>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg15703.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agoDon't throw fatal errors from create_temp_file()
Steffan Karger [Wed, 1 Nov 2017 22:03:41 +0000 (23:03 +0100)] 
Don't throw fatal errors from create_temp_file()

This function is called in response to connecting clients, and can fail
when I/O fails for some (possibly temporary) reason.  In such cases we
should not exit the process, but just reject the connecting client.

This commit changes the function to actually return NULL on errors, and
(where needed) changes the callers to check for and handle errors.

Since the tls-crypt-v2 metadata code also calls create_temp_file() when
clients connect, I consider this a prerequisite for tls-crypt-v2.

Signed-off-by: Steffan Karger <steffan.karger@fox-it.com>
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Message-Id: <20171101220342.14648-4-steffan@karger.me>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg15701.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agopf: reject client if PF plugin is configured, but init fails
Steffan Karger [Wed, 1 Nov 2017 22:03:40 +0000 (23:03 +0100)] 
pf: reject client if PF plugin is configured, but init fails

This changes the behavior for pf plugins: instead of just not initializing
the firewall rules and happily continuing, this now rejects the client in
the case of an (unlikely) failure to initialize the pf.

Signed-off-by: Steffan Karger <steffan@karger.me>
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Message-Id: <20171101220342.14648-3-steffan@karger.me>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg15704.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agopf: clean up temporary files if plugin init fails
Steffan Karger [Wed, 1 Nov 2017 22:03:39 +0000 (23:03 +0100)] 
pf: clean up temporary files if plugin init fails

close_instance() tries to remove the file in c2.pf.filename, but that only
works if we actually set that if we fail.  So, set that filename as soon
as we know we've created the file.

Signed-off-by: Steffan Karger <steffan.karger@fox-it.com>
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Message-Id: <20171101220342.14648-2-steffan@karger.me>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg15705.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agoFix build with LibreSSL
Jeremie Courreges-Anglas [Sun, 19 Nov 2017 21:57:56 +0000 (22:57 +0100)] 
Fix build with LibreSSL

Detect the presence of SSL_CTX_set_security_level(), don't check
OPENSSL_VERSION_NUMBER.

Signed-off-by: Jeremie Courreges-Anglas <jca@wxcvbn.org>
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Message-Id: <8760a6kjwc.fsf@ritchie.wxcvbn.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg15902.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agoAdd generated openvpn.doxyfile to .gitignore
Gert van Dijk [Sat, 11 Nov 2017 17:14:06 +0000 (18:14 +0100)] 
Add generated openvpn.doxyfile to .gitignore

I think this was omitted in 66bf378e.

Signed-off-by: Gert van Dijk <gert@gertvandijk.net>
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Message-Id: <20171111171406.7562-1-gert@gertvandijk.net>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg15826.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agoAdd --tls-cert-profile option.
Steffan Karger [Sun, 12 Nov 2017 16:36:36 +0000 (17:36 +0100)] 
Add --tls-cert-profile option.

This allows the user to specify what certificate crypto algorithms to
support.  The supported profiles are 'preferred', 'legacy' (default) and
'suiteb', as discussed in <84590a17-1c48-9df2-c48e-4160750b2e33@fox-it.com>
(https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg14214.
html).

This fully implements the feature for mbed TLS builds, because for mbed it
is both more easy to implement and the most relevant because mbed TLS 2+
is by default somewhat restrictive by requiring 2048-bit+ for RSA keys.

For OpenSSL, this implements an approximation based on security levels, as
discussed at the hackathon in Karlsruhe.

This patch uses 'legacy' as the default profile following discussion on
the openvpn-devel mailing list.  This way this patch can be applied to
both the release/2.4 and master branches.  I'll send a follow-up patch for
the master branch to change the default to 'preferred' later.

Signed-off-by: Steffan Karger <steffan.karger@fox-it.com>
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Message-Id: <20171112163636.17434-1-steffan@karger.me>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg15848.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agoAdd per session pseudo-random jitter to --reneg-sec intervals
Simon Matter [Thu, 16 Nov 2017 14:09:58 +0000 (15:09 +0100)] 
Add per session pseudo-random jitter to --reneg-sec intervals

While we were suffering from the "TLS Renegotiation Slowdown" bug here
https://community.openvpn.net/openvpn/ticket/854 we realized that there is
still room for improvement in our use case.

It appears that TLS renegotiation is getting more and more expensive in
terms of CPU cycles with recent changes for more security. To make things
worse, we realized that most renegotiation procedures took place at almost
the same time and increased the CPU load too much during these periods.
That's especially true on large, multi-instance openvpn setups.

I've created attached patch to add a per session pseudo-random component to
the --reneg-sec intervals so that renegotiation is evenly spread over time.
It is configured by simply adding a second value to --reneg-sec as
described in the --help text:

--reneg-sec max [min] : Renegotiate data chan. key after at most max
                  (default=3600) and at least min (default 90% of max on
                  servers and equal to max on clients).

The jitter is only enabled by default on servers, because the actual reneg
time is min(reneg_server, reneg_client).  Introducing jitter at both ends
would bias the actual reneg time to the min value.

Note that the patch also slightly changes the log output to show the sec
value in the same way as the bytes/pkts values:

TLS: soft reset sec=3084/3084 bytes=279897/-1 pkts=1370/0

The idea and first versions of this patch are from Simon Matter.  Steffan
Karger later incorporated the mailing list comments into this patch.  So
credits go to Simon, and all bugs are Steffan's fault ;-)

Signed-off-by: Simon Matter <simon.matter@invoca.ch>
Signed-off-by: Steffan Karger <steffan@karger.me>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20171116140958.12847-1-steffan@karger.me>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg15888.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agoRemove warning on pushed tun-ipv6 option.
Gert Doering [Sat, 11 Nov 2017 14:22:30 +0000 (15:22 +0100)] 
Remove warning on pushed tun-ipv6 option.

tun-ipv6 is a no-op nowadays, and we print a warning to let users know -
which is not helpful for server-pushed tun-ipv6 (which might be the
result of --server-ipv6 automatically pushing this).  So, remove the
warning if parsing pushed options.

Also, remove the VERIFY_PERMISSION() call here which has side effects
on the "which class of options got pushed, do we need to act on them
later on?" flag set.

v2: use existing pull_mode flag

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20171111142230.3288-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/search?l=mid&q=20171111142230.3288-1-gert@greenie.muc.de
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agoSimplify and inline clear_buf()
Steffan Karger [Fri, 10 Nov 2017 11:08:58 +0000 (12:08 +0100)] 
Simplify and inline clear_buf()

Such a simple operation should not need a full function call.

Signed-off-by: Steffan Karger <steffan@karger.me>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20171110110858.11482-1-steffan@karger.me>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg15796.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agoUse long long to format time_t-related environment variables
Jeremie Courreges-Anglas [Sun, 5 Nov 2017 09:46:41 +0000 (10:46 +0100)] 
Use long long to format time_t-related environment variables

Signed-off-by: Jeremie Courreges-Anglas <jca@wxcvbn.org>
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Message-Id: <20171105094641.55673-1-jca@wxcvbn.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg15750.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agoCast and print another suseconds_t as long
Jeremie Courreges-Anglas [Sun, 5 Nov 2017 09:03:26 +0000 (10:03 +0100)] 
Cast and print another suseconds_t as long

Missed in 31b5c0e
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Message-Id: <87375t6qas.fsf@ritchie.wxcvbn.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg15749.html

Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agodoxygen: add make target and use relative paths
Steffan Karger [Wed, 8 Nov 2017 12:12:54 +0000 (13:12 +0100)] 
doxygen: add make target and use relative paths

Add a make target, such that 'make doxygen' works (both for in-tree and
out-of-tree builds).  This now generates the doxygen in doc/doxygen/,
rather than in doxygen/.

While doing so, instead of genering docs with full path names (e.g.
/home/steffan/dev/openvpn/src/openvpn/crypto.h), use a relative path wrt
the project root (e.g. src/openvpn/crypto.h) in the generated
documentation.  This makes the generated doxygen easier to read.

Signed-off-by: Steffan Karger <steffan.karger@fox-it.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1510143174-15248-1-git-send-email-steffan.karger@fox-it.com>
URL: https://www.mail-archive.com/search?l=mid&q=1510143174-15248-1-git-send-email-steffan.karger@fox-it.com
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agobuffer_list_aggregate_separator(): add unit tests
Steffan Karger [Sat, 4 Nov 2017 22:45:50 +0000 (23:45 +0100)] 
buffer_list_aggregate_separator(): add unit tests

Before refactoring this function, add tests to verify the new
implementation.

While writing the tests, it became clear that this function is not
behaving very well.  We'll fix that in follow-up commits.

Signed-off-by: Steffan Karger <steffan.karger@fox-it.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20171104224551.3079-1-steffan@karger.me>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg15748.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agosystemd: Add and ship README.systemd
David Sommerseth [Mon, 27 Mar 2017 22:16:20 +0000 (00:16 +0200)] 
systemd: Add and ship README.systemd

This new README file describes how to use the new
openvpn-client@.service and openvpn-server@.service unit files properly.

The purpose of this file is primarily for all systemd based
distributions to have a common set of documentation.

Signed-off-by: David Sommerseth <davids@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20170327221620.24639-1-davids@openvpn.net>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg14311.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agoMSVC meta files added to .gitignore list
Simon Rozman [Tue, 10 Oct 2017 23:11:25 +0000 (01:11 +0200)] 
MSVC meta files added to .gitignore list

Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20171010231130.6832-8-simon@rozman.si>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg15585.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agoUniform swprintf() across MinGW and MSVC compilers
Simon Rozman [Fri, 13 Oct 2017 09:50:08 +0000 (11:50 +0200)] 
Uniform swprintf() across MinGW and MSVC compilers

Legacy _snwprintf() and snwprintf() functions replaced with ISO C
swprintf().

Assigning _snwprintf() return value to unused variable was also removed
at one occasion.
Acked-by: Selva Nair <selva.nair@gmail.com>
Message-Id: <20171013095008.8288-1-simon@rozman.si>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg15633.html

Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agoFix typo in "verb" command examples
Simon Rozman [Wed, 11 Oct 2017 13:49:02 +0000 (15:49 +0200)] 
Fix typo in "verb" command examples

Acked-by: David Sommerseth <davids@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20171011134902.3876-1-simon@rozman.si>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg15601.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agoDocument ">PASSWORD:Auth-Token" real-time message
Simon Rozman [Wed, 11 Oct 2017 13:45:30 +0000 (15:45 +0200)] 
Document ">PASSWORD:Auth-Token" real-time message

Authentication tokens are security enhancement eliminating client
need to cache passwords, and are indispensable at two factor
authentication methods, such as HOTP or TOTP.

The ">PASSWORD:Auth-Token" message was not mentioned anywhere in
the OpenVPN Management Interface Notes. This patch adds a simple use
case example, while the more detailed feature description remains
explained in the OpenVPN manual.
Acked-by: David Sommerseth <davids@openvpn.net>
Message-Id: <20171011134530.6676-1-simon@rozman.si>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg15599.html

Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agoFix local #include to use quoted form
Simon Rozman [Thu, 12 Oct 2017 10:34:48 +0000 (12:34 +0200)] 
Fix local #include to use quoted form

.h include files from the same folder or addressed relatively to the
same folder should be #included using quoted form in MSVC. The angled
form is reserved for include files from folders specified using /I
path.

Using angled form, MSVC fails to locate local #include file, unless
current folder is added to the include search path: /I .
Acked-by: Selva Nair <selva.nair@gmail.com>
Message-Id: <20171012103448.7632-1-simon@rozman.si>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg15622.html

Signed-off-by: Gert Doering <gert@greenie.muc.de>