0
0
mirror of https://github.com/OpenVPN/openvpn3.git synced 2024-09-20 20:13:05 +02:00
Commit Graph

44 Commits

Author SHA1 Message Date
Lev Stipakov
6f266be3d8 wintun: ring buffers support
Implemented according to Wintun documentation
and reference client code.

For send and receive ring, client allocates buffer,
creates event and passes it to Wintun under LocalSystem
privileges. When data is availabe for read, Wintun
moves tail pointer of send ring and signals via
send ring's event. To write, client writes to tail
pointer of receive ring and signals via receive ring's event.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2019-08-21 17:58:37 +03:00
James Yonan
c3c45c9b38
tun: added Error::TUN_HALT for tun_error() signaling
Error::TUN_HALT, when passed up via tun_error(), now
sends an Explicit Exit Notify message before disconnect.

Signed-off-by: James Yonan <james@openvpn.net>
2019-06-19 18:35:20 +02:00
Antonio Quartulli
9814079944
tls-crypt-v2: implement abstract metadata parser
The metadata that may be possibly be contained in the WKc has to be
verified by means of a user implemented behaviour.

Implement an abstract class that exports a verify() method to be
used for this purpose.

Users can extend this class and override the verify() method with
their own.

A basic implementation is also provided: it will just ignore the
metadata (if any) and report success to the core.

Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
2018-12-06 09:19:22 +10:00
David Sommerseth
16b10559f2 [OVPN3-140] Update company names in copyrights
OpenVPN Technologies, Inc. change their name to OpenVPN Inc. during the
autumn of 2017.

Signed-off-by: David Sommerseth <davids@openvpn.net>
2017-12-22 17:59:39 +08:00
David Sommerseth
6caca2c313 [OVPN3-140] Relicense back to AGPLv3
This is essentially a revert of commit 04b2a3c9b7 and commit
ef42e59e05.

Signed-off-by: David Sommerseth <davids@openvpn.net>
2017-12-22 17:59:39 +08:00
James Yonan
b2cd82a5bf copyright: updated to 2017.
Signed-off-by: James Yonan <james@openvpn.net>
2017-03-18 13:11:09 -06:00
James Yonan
9c0397ebd3 Added Relay capability, a kind of proxy function similar
to HTTP CONNECT but implemented over the OpenVPN protocol.

1. Client connects to relay server as if it were connecting
   to an ordinary OpenVPN server.

2. Client authenticates to relay server using its client
   certificate.

3. Client sends a PUSH_REQUEST method to relay server which
   then replies with a RELAY message instead of PUSH_REPLY.

4. On receiving the RELAY message, the client attempts to
   reconnect using the existing transport socket.  The
   server will proxy this new connection (at the transport
   layer) to a second server (chosen by the relay server)
   that is the target of proxy.

5. The client must establish and authenticate a new session
   from scratch with the target server, only reusing the
   transport layer socket from the original connection to
   the relay server.

6. The relay acts as a man-in-the-middle only at the
   transport layer (like most proxies), i.e. it forwards
   the encrypted session between client and target server
   without decrypting or having the capability to decrypt
   the session.

7. The client is designed to protect against potentially
   untrusted or malicious relays:

   (a) The client never transmits the target server
       username/password credentials to the relay server.

   (b) The relay forwards the encrypted OpenVPN session
       between client and target server without having
       access to the session keys.

   (c) The client configuration has a special directive
       for relay server CA (<relay-extra-ca>) and relay
       server tls-auth key (<relay-tls-auth>) to allow
       for separation of TLS/crypto configuration between
       relay and target servers.

   (d) The client will reject any PUSH_REPLY messages
       from the relay itself to prevent the relay from
       trying to establish a tunnel directly with the
       client.

Example configuring a client for relay:

  # remote addresses point to the relay server
  remote ... 1194 udp
  remote ... 443 tcp

  # include all other directives for connecting
  # to the target server

  # enable relay mode
  relay-mode

  # constrain the relay server's cert type
  relay-ns-cert-type server

  # include extra CAs that validate the relay
  # server cert (optional).
  <relay-extra-ca>
  -----BEGIN CERTIFICATE-----
  . . .
  -----END CERTIFICATE-----
  </relay-extra-ca>

  # specify the TLS auth key for the relay server
  relay-key-direction 1
  <relay-tls-auth>
  -----BEGIN OpenVPN Static key V1-----
  . . .
  -----END OpenVPN Static key V1-----
  </relay-tls-auth>
2017-03-18 12:24:54 -06:00
Samuli Seppänen
04b2a3c9b7 Switch from AGPLv3 to GPLv3
Signed-off-by: Samuli Seppänen <samuli@openvpn.net>
2017-03-16 14:43:55 +02:00
James Yonan
971abda88f copyright : updated to 2016 2016-09-03 23:29:23 -06:00
James Yonan
662bf7833e ovpn3 core : Added automatic data limits for Blowfish,
Triple DES, and other 64-bit block-size ciphers vulnerable
to "Sweet32" birthday attack (CVE-2016-6329).  Limit such
cipher keys to no more than 64 MB of data
encrypted/decrypted.  While our overall goal is to limit
data-limited keys to 64 MB, we trigger a renegotiation
at 48 MB to compensate for possible delays in renegotiation
and rollover to the new key.

This client-side implementation extends data limit
protection to the entire session, even when the server
doesn't implement data limits.

This capability is advertised to servers via the a
peer info setting:

  IV_BS64DL=1

meaning "Block-Size 64-bit Data Limit".  The "1" indicates
the implementation version.

The implementation currently has some limitations:

* Keys are renegotiated at a maximum rate of once per
  5 seconds to reduce the likelihood of loss of
  synchronization between peers.

* The maximum renegotiation rate may be further extended
  if the peer delays rollover from the old to new key
  after renegotiation.

Added N_KEY_LIMIT_RENEG stats counter to count the number
of data-limit-triggered renegotiations.

Added new stats counter KEY_STATE_ERROR which roughly
corresponds to the OpenVPN 2.x error "TLS Error:
local/remote TLS keys are out of sync".

Prevously, the TLS ack/retransmit timeout was hardcoded to
2 seconds.  Now we lower the default to 1 second and make
it variable using the (pushable) "tls-timeout" directive.
Additionally, the tls-timeout directive can be specified
in milliseconds instead of seconds by using the
"tls-timeout-ms" form of the directive.

Made the "become primary" time duration configurable via
the (pushable) "become-primary" directive which accepts
a number-of-seconds parameter.  become-primary indicates
the time delay between renegotiation and rollover to the
new key for encryption/transmission.  become-primary
defaults to the handshake-window which in turn defaults
to 60 seconds.

Incremented core version to 3.0.20.
2016-09-01 15:19:00 -06:00
James Yonan
86d7729794 clievent : distinguish between 3 event categories
(instead of 2):

(a) ordinary events such as CONNECTING, CONNECTED,
(b) nonfatal errors such as TRANSPORT_ERROR that will
    automatically trigger a reconnect, and
(c) fatal errors such as AUTH_FAILED, that will be followed
    by a DISCONNECT

In ClientAPI::Event, added a new "fatal" boolean to indicate
when errors are fatal.

Added a new non-fatal event TUN_ERROR that triggers a
reconnect when errors are indicated in tunio.hpp.
2016-03-31 20:24:28 -06:00
James Yonan
0bac5d8990 Core: revamped packet ID code to use a much larger window size,
allowing backtracks of up to 2048 (previous limit was 64).
In addition, we now maintain the packet ID window as a bit
array (previously a byte array was used).
2015-06-18 01:55:52 -06:00
James Yonan
5d1bc1c952 Moved array_size() function to its own header file. 2015-05-17 12:57:23 -06:00
James Yonan
c2c7292a70 Updated copyright to 2015. 2015-01-06 12:56:21 -07:00
James Yonan
0c91391bae Added C++11 array_size method that is constexpr so it can be used
for compile-time asserts.

Use C++11 static_assert and array_size to verify size consistency
of tables in openvpn/error/error.hpp.
2014-10-23 13:44:52 -06:00
James Yonan
f5b71c8d43 Merge branches 'server.20140819' and 'ios-tun-persist.20140816' 2014-08-23 01:12:46 -06:00
James Yonan
17ca7f440a Added new explicit TRANSPORT_ERROR event that is triggered when
the transport layer socket (UDP, TCP, or HTTP proxy) encounters
a send error that indicates potential network reconfiguration
at the system level.

TRANSPORT_ERROR will trigger a core-level reconnect in 5 seconds
(higher than the usual 2), and also notify the higher levels
(above ClientAPI::OpenVPNClient), allowing them to schedule
their own network reachability tests to preempt the default
5-second reconnect.
2014-08-22 15:32:35 -06:00
James Yonan
d87a9e3c1e Server development initial checkpoint:
1. UDP server
2. Client instance objects

No routing, authentication, or management.

Server will negotiate a client then push AUTH_FAILED.
2014-08-19 01:13:42 -06:00
James Yonan
d9b5cdf588 Core: SSL layer changes:
* Renamed SSL method write_ciphertext_ready() to
  read_cleartext_ready() for clarity.

* It's important that read_cleartext_ready() returns an accurate
  status.  To this end, add ssl_get_bytes_avail to the return
  expression for PolarSSL:

    return !ct_in.empty() || ssl_get_bytes_avail(ssl);

  This will also consider buffering inside of PolarSSL,
  and avoid potential deadlocks.

  Other SSL modules (AppleCrypto and OpenSSL) have been
  commented to warn of this issue.

* Factored out constants such as SHOULD_RETRY to namespace
  SSLConst.

* Added flags var to SSL configs.

* Added new SSL flag LOG_VERIFY_STATUS.  If disabled,
  makes for a quiet SSL negotiation if no errors.

* Detect SSL partial writes and designate a new error status
  code (SSL_PARTIAL_WRITE).

* In ProtoStackBase, detect unclassified errors from SSL layer
  (throw unknown_status_from_ssl_layer).

* PolarSSL module now recognizes Close Notify status and returns
  SSLConst::PEER_CLOSE_NOTIFY.

* In ProtoStackBase, factored out some error handling into
  common method.
2014-08-10 19:34:00 -06:00
James Yonan
2c6d972ad6 Added AGPL copyright/licensing language. 2014-07-20 21:22:06 -06:00
James Yonan
11acfc6ca2 Implemented Mac connection lifecycle monitoring object
(MacLifeCycle).

Monitor connection lifecycle notifications, such as sleep, wakeup,
network-unavailable, and network-available.

Note that not all platforms define a lifecycle object.  Some
platforms such as Android and iOS manage lifecycle notifications at
the service level, and they call pause(), resume(), reconnect(),
etc. as needed using the main ovpncli API.

Also, added a reason string to Pause event.
2014-03-24 17:28:46 -06:00
James Yonan
282556997c Added TunIO callback tun_error_handler() to inform parent
of errors.  Use this callback to detect STATUS_CANCELLED
returns from Windows TAP driver which translates to
ERROR_OPERATION_ABORTED 995 (0x3E3) from userspace.
This will trigger a fatal error in the client
Error::TUN_IFACE_DISABLED ("TAP adapter is disabled").
2014-02-21 12:47:03 -07:00
James Yonan
2198df06f2 Added tls-version-min directive:
tls-version-min <version> ['or-highest'] -- sets the minimum
TLS version we will accept from the peer.  Examples for version
include "1.0", "1.1", or "1.2".  If 'or-highest' is specified
and version is not recognized, we will only accept the highest TLS
version supported by the local SSL implementation.

Examples:

tls-version-min 1.1 -- fail the connection unless peer can
  connect at TLS 1.1 or higher.

tls-version-min 1.3 or-highest -- require that the peer
  connect at TLS 1.3 or higher, however if the local SSL
  implementation doesn't support TLS 1.3 (as it wouldn't in 2013
  since TLS 1.3 doesn't exist yet), reduce the minimum required
  version to the highest version supported by the local SSL
  implementation (such as TLS 1.2).  This is intended to allow
  client configurations to target higher TLS versions that are
  supported on the server, even if some older clients don't
  support these versions yet.
2013-06-06 22:18:17 +00:00
James Yonan
926504ec4c Implemented "inactive" directive. 2013-05-25 01:19:50 +00:00
James Yonan
9262e131b7 "Session invalidated" errors will now explicitly reference a reason code. 2013-05-22 07:46:52 +00:00
James Yonan
82be8b0107 packet_id.hpp now logs errors to a SessionStats objects,
like the rest of the core.

Added verbose() method to class SessionStats so that clients can
know whether to pass extra text data to error() virtual method.
2013-05-22 05:13:11 +00:00
James Yonan
de0da474ef Revamp remote-list handling so that DNS names that resolve to
multiple addresses will be treated as if each address was an
individual remote directive.

Fixed issue where UDP transport driver was calling socket
connect method synchronously.  This can cause exceptions
to be thrown in corner cases, such as "No route to host"
on OSX/iOS for connections to IPv6 addresses when no default
IPv6 route exists on system.  Refactoring UDP connect
operation to be asychronous fixes the issue.

Implemented remote-random.
2013-03-12 19:20:37 +00:00
James Yonan
400b7324da In Android client, added a custom error dialog for
TAP-based tunnels not supported.
2012-12-12 02:19:07 +00:00
James Yonan
4d9a751af2 Added head comments to all source files.
Minor reorganization of unicode code.
2012-11-23 06:18:43 +00:00
James Yonan
34a2fd7047 Add error code for PEM_PASSWORD_FAIL for conveying error up
through client API.
2012-11-16 04:13:48 +00:00
James Yonan
0d16acd0bb Minor exception code cleanup. 2012-11-14 16:41:33 +00:00
James Yonan
87fd344e6e Did some refactoring to make it easier for tun and transport objects
to communicate specific errors or warnings.

Added TUN_IFACE_CREATE event, which indicates an error creating
the tun interface.

Added REROUTE_GW_NO_DNS error stat, which indicates that
redirect-gateway (IPv4) was processed without an accompanying
DNS directive.
2012-10-24 09:32:15 +00:00
James Yonan
3ca3a857bd Initial HTTP proxy implementation in core, with support for
non-authenticated proxies and Basic Auth.

Includes new PROXY_ERROR and PROXY_NEED_CREDS events.

Still to do: Digest and NTLM auth.
2012-10-24 06:38:20 +00:00
James Yonan
790d6ba5fb Added two new stats to client core:
N_PAUSE -- number of times that Pause state has been entered
N_RECONNECT -- number of reconnections
2012-10-21 11:32:06 +00:00
James Yonan
a6b6d487ef Global edit to add copyright notice at head of each source file. 2012-08-24 21:13:42 +00:00
James Yonan
f91339e739 First working iOS build. 2012-07-01 15:37:46 +00:00
James Yonan
6fb53c3abb Fixed a race condition issue with "hot connect", i.e. sending a
connect intent to service when already connected.  

One of the ramifications of the "hot connect" fix above is that
OpenVPNClientBase.is_active() will now return a value that is
instantaneously up-to-date, whereas events might lag because
of the mechanics of inter-thread message posting.  Keep this in
mind when correlating received events to is_active() values.

For C++ core threads, increased allowed thread-stop delay to 2.5
seconds before thread is marked as unresponsive and abandoned.
Previous delay was 1 second.  This delay can't be made too long,
otherwise Android will tell the user that the app is unresponsive
and invite them to kill it.

When closing out an abandoned core thread, indicate this condition
with a new event type called CORE_THREAD_ABANDONED.  If the thread
is abandoned due to lack of response to a disconnect request, then
the CORE_THREAD_ABANDONED event will occur followed by
CORE_THREAD_INACTIVE.  For core threads that properly exit,
the DISCONNECTED event will be followed by CORE_THREAD_INACTIVE.

Added save_as_filename parameter to importProfileRemote method for
controlling the filename that the imported profile is saved as.
This parameter may be set to null to have the method choose an
appropriate name.  To have an imported profile replace an existing
profile, the filenames much match.

Added UI_OVERLOADED debugging constant to OpenVPNClient to allow
the UI to connect to a profile when already connected to another
profile in order to test "hot connect".

Added new events CLIENT_HALT and CLIENT_RESTART for compatibility
with an Access Server feature that allows the server to remotely
kill or restart the client.

When connecting a profile, the core will now automatically fill in
the username if it is not specified for userlocked profiles.

Version 0.902.
2012-03-31 16:08:20 +00:00
James Yonan
b13a527308 Android 4:
* Implemented connection timeout.
* Implemented show raw stats page.
* Work around issue where sometimes core doesn't stop when
  stop() method is called, because of delays in canceling
  Asio DNS resolution thread.
2012-03-07 11:21:09 +00:00
James Yonan
f094241aa8 Android 4 client port is almost working (need to get an Android
build that includes tun driver to test further).
2012-02-19 01:36:50 +00:00
James Yonan
9f5cfc465a Implement error handling if socket_protect() call fails. 2012-02-17 20:30:08 +00:00
James Yonan
1f5e50d733 Implemented OpenVPNClient stats methods.
Simplified autologin sensing.
Java test client will now dump stats on exit.
2012-02-12 23:09:28 +00:00
James Yonan
adbc10fb5e Bug fixes:
* raise default headroom/tailroom to 512 for worst-case compression
  expansion

* for TCP connections use async_connect instead of connect

* for Time and Time::Duration, handle subtraction reasonably with
  infinite values

* handle possible infinite duration in to_posix_duration

* fix overflow in Time::Duration::to_milliseconds

* call Base::update_now() in ClientProto::start
2012-02-07 20:52:40 +00:00
James Yonan
6674709aba Added ClientConnect class which implements an "always-try-to-reconnect"
approach, with remote list rotation.  Only gives up on auth failure.
2012-02-07 11:37:35 +00:00
James Yonan
e7a5d9f55b Start process of moving client logic out of cli.cpp into
general-purpose classes.

Rename ProtoStats to SessionStats and make it more flexible
by using an abstract base class model.

Add a client event queue for the beginnings of a client-backend
API.

Added logic to ProtoContext to invalidate session on certain
kinds of errors in TCP that would be normally be okay in UDP
such as HMAC_ERROR, DECRYPT_ERROR, etc.

Add some alignment adjustment logic for READ_LINK_TCP (3 bytes)
and READ_LINK_UDP (1 byte).
2012-02-04 10:24:54 +00:00