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

49 Commits

Author SHA1 Message Date
Heiko Hund
be3f20dc58 introduce base types for strong and weak RNGs
The need of having to call the assert_crypto() member function to ensure
that a cryptographically strong RNG is used where needed, was reported
as potentially insecure, since calling it manually can easily be missed.

In the commit the two new classes StrongRandomAPI and WeakRandomAPI are
introduced. They are to be used instead of just RandomAPI, unless it
doesn't matter what strength the RNG is.

All the places the assert_crypto() was called were converted to using
StrongRandomAPI instead. Also the RNGs for which assert_crypto() was not
throwing are now inheriting from StrongRandomAPI.

Variable names, which have the StrongRandomAPI type, but were called
prng, are changed to rng instead to follow the source code convention.

Signed-off-by: Heiko Hund <heiko@openvpn.net>
2023-11-22 04:49:31 +01:00
Lev Stipakov
97b3c0a594 Add route tables manipulation functionality
This adds two routines:

  AWS::Route::create_route_table

This creates route table in given VPC and
assigns "Name" tag to it with provided value.

  AWS::Route::get_route_table_by_name

This searches for route table with given "Name"
tag and either returns route table id or empty string
if route table doesn't exist.

These routines are used by Linux client AWS addon.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2023-10-26 12:12:58 +00:00
Lev Stipakov
1b11c994ab aws: support for IMDSv2
IMDSv2 requires to obtain token for instance metadata requests

  https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instance-metadata-v2-how-it-works.html

IMDSv2 works on all reasonably modern instances and can be optionally
forced to be used instead of v1.

Fixes https://github.com/OpenVPN/openvpn3-linux/issues/192

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2023-07-05 09:05:45 +00:00
Lev Stipakov
528ec40c11 aws: fix ReplaceRoute error handling
Commit 5b524b1f ("WS::ClientSet: added new TransactionSet flag
retry_on_http_4xx") sets E_BAD_REQUEST transport status in case of
HTTP 400. This breaks replace_create_route() behavior, which
doesn't expect transport error for ReplaceRoute and fails the
whole transaction set.

Fix by setting retry_on_http_4xx flag to false before executing
ReplaceRoute. We expect to get 400 if route doesn't exist, so no
need to retry.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2023-07-04 14:07:55 +00:00
Arne Schwabe
d5c09e2b08
Do not allow SHA1 cipher suites when using preferred tls-cert-profile
We do not allow SHA1 in other instances using this profile and while
SHA1 is still fine as HMAC in these situation, people freak out when
seeing SHA1 and also the description and documentation will state
that SHA1 is not allowed in other context (certificate signature),
causing confusion. So better not allow it in this context as well.

Signed-off-by: Arne Schwabe <arne@openvpn.net>
2023-03-29 23:14:30 +02:00
David Sommerseth
dde1574596
Reformatting source code to new coding style
This is the result after running 'clang-format -i' on all C++ files and
headers, with the defined formatting rules in .clang-format.

Only the openvpn/common/unicode-impl.hpp has been excluded, as that is
mostly a copy of an external project.

Signed-off-by: David Sommerseth <davids@openvpn.net>
2023-01-18 19:24:15 +01:00
David Sommerseth
4996c38ed4
Merge lastest changes from Core v3.7.2 2022-12-14 17:34:29 +01:00
David Sommerseth
8c94a8f774
copyright: Update to 2022
Signed-off-by: David Sommerseth <davids@openvpn.net>
2022-09-29 12:00:26 +02:00
James Yonan
5b524b1f86 WS::ClientSet: added new TransactionSet flag retry_on_http_4xx
When enabled, retry_on_http_4xx indicates that HTTP status
codes between 400 and 499 should be considered a
retryable error.  AWS appears to need this.

Note that error codes between 500 and 599 are always
considered to be retryable.

Signed-off-by: James Yonan <james@openvpn.net>
2022-06-29 08:39:22 -06:00
James Yonan
b2df3ca663 Renamed VPN_CONNECTION_PROFILES -> VPN_BINDING_PROFILES for clarity
VPN Binding Profiles (previously committed as VPN Connection
Profiles) contain information on an active VPN client session
such as local VPN IPs, gateway, and DNS resolver addresses
that can be directly used by higher-layer HTTP/REST-API
clients to (a) ensure that sessions are routed over the VPN,
and (b) privately use the VPN-server-pushed DNS resolvers
without publishing them in /etc/resolv.conf.

Signed-off-by: James Yonan <james@openvpn.net>
2022-06-29 08:39:22 -06:00
James Yonan
c48b3d8000 AWS::PCQuery: capture AZ (availabilityZone) as well
Signed-off-by: James Yonan <james@openvpn.net>
2022-06-29 08:39:22 -06:00
James Yonan
9b5d87fd43 HTTP client/server: support binding to VPN connection profiles
A VPN connection profile is basically a JSON representation
of the server-pushed parameters of a VPN session such as
VPN IPs, Gateway IPs, and DNS servers.  It can be obtained
on the client via TunBuilderCapture::to_json()

This patch allows an HTTP client or server to bind to the
VPN connection profile, so that the VPN IP is used as the
local address, the Gateway IP is optionally used as the
destination address, and DNS lookups are performed using
the pushed DNS servers (without needing to overwrite
/etc/resolv.conf).

For example, suppose the VPN connection profile
is in /pg/uplink-connection-info

Then we can bind to the VPN IP addresses on the server side:

  http-listen @/pg/uplink-connection-info 8443 tcp4 ssl
  http-listen @/pg/uplink-connection-info 8443 tcp6 ssl

Or connect to a remote REST API using the VPN session
and VPN server-provided resolvers.

  <aws-client>
  host mybucket.s3.amazonaws.com
  port 443
  vpn-connection-info /pg/uplink-connection-info
  ...
  </aws-client>

Signed-off-by: James Yonan <james@openvpn.net>
2022-05-14 01:39:37 -06:00
James Yonan
96d6d487be AWS::Creds: added a template constructor to allow initialization from other kinds of credential classes
Signed-off-by: James Yonan <james@openvpn.net>
2022-05-13 19:09:09 -06:00
James Yonan
f1a1776eee AWS::api_ca(): use file_exists() function to test for file existence
Signed-off-by: James Yonan <james@openvpn.net>
2022-05-13 19:09:09 -06:00
Lev Stipakov
bf9f309f6f
awsca.hpp: use proper CA path
Different distros store CA certs in different places.

Try paths one by one until CA is found and
throw exception if not.

This is required to make AWS Addon for Linux client
work on non-Debian based distros.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2020-07-23 19:09:45 +02:00
Lev Stipakov
c39bd17b90 aws: use external certificates for pkcs7 signature validation
Load AWS certificates from provided directory and use them
for pkcs7 signature validation. If directory is not provided,
use default hardcoded certificate.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2020-07-22 11:45:13 +00:00
Lev Stipakov
b2e8cb42f0
Add GPL headers
Signed-off-by: Lev Stipakov <lev@openvpn.net>
2020-02-05 20:08:58 +02:00
Lev Stipakov
b8ff04be75
aws: support for temporary credentials
- add optional token parameter, which is required when
using temporary credentials

 - add optional role parameter to fetch
temporary credentials

 - make route API param more fine grained

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2020-02-05 20:08:54 +02:00
James Yonan
fae6a3d62f
AWS::REST: support S3 request signing
Signed-off-by: James Yonan <james@openvpn.net>
2020-02-05 20:08:53 +02:00
James Yonan
c21de25c1f
copyright: updated to 2017
Signed-off-by: James Yonan <james@openvpn.net>
2020-02-05 20:08:53 +02:00
James Yonan
702b3a81b7
AWS: created mini-SDK for VPC routing API. 2020-02-05 20:08:52 +02:00
Lev Stipakov
1a4bff66af
aws: support for temporary credentials
- add optional token parameter, which is required when
using temporary credentials

 - add optional role parameter to fetch
temporary credentials

 - make route API param more fine grained

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2020-02-05 20:08:52 +02:00
James Yonan
b84345dfa6
AWS C++: AWS::Creds: added defined() and to_string() methods
Signed-off-by: James Yonan <james@openvpn.net>
2020-02-05 20:08:51 +02:00
James Yonan
1324be80f6
copyright: updated to 2017
Signed-off-by: James Yonan <james@openvpn.net>
2020-02-05 20:08:50 +02:00
James Yonan
86480f71f5
AWS: created mini-SDK for VPC routing API. 2020-02-05 20:08:50 +02:00
Lev Stipakov
d534049f5e
aws: support for temporary credentials
- add optional token parameter, which is required when
using temporary credentials

 - add optional role parameter to fetch
temporary credentials

 - make route API param more fine grained

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2020-02-05 20:08:49 +02:00
James Yonan
1af01f3e20
Minor SNI-related changes to code that depends on the SSL layer
Signed-off-by: James Yonan <james@openvpn.net>
2020-02-05 20:08:49 +02:00
James Yonan
d186d8b66e
WS::ClientSet: misc changes
* HostRetry, which is essentially a string vector, now
  inherits directly from std::vector<std::string>

* WS::ClientSet doesn't need a crypto-grade RNG, so rename
  rng to prng.

* WS::ClientSet almost always contains a single client
  object, so use std::map instead of std::unordered_map
  to contain it so as to reduce overhead.

Signed-off-by: James Yonan <james@openvpn.net>
2020-02-05 20:08:48 +02:00
James Yonan
e895716717
Added i/o abstraction layer.
Created a lightweight abstraction layer so that another i/o
reactor can be dropped in place of asio.

This commit includes:

* Added ASIO=1 to many "go" scripts that require asio
* Renamed "asio::" to "openvpn_io::".

Signed-off-by: James Yonan <james@openvpn.net>
2020-02-05 20:08:48 +02:00
James Yonan
3d3e3ec767
copyright: updated to 2017
Signed-off-by: James Yonan <james@openvpn.net>
2020-02-05 20:08:47 +02:00
James Yonan
8a08aba016
random : RandomAPI::assert_crypto() should now be called before any RNG is used for crypto purposes. 2020-02-05 20:08:47 +02:00
James Yonan
671c0beb99
AWS : minor changes to AWS::PCQuery:
1. added new method AWS::PCQuery::Info::instance_data_defined()
2. added some missing includes
2020-02-05 20:08:46 +02:00
James Yonan
1fab99f436
AWS : created AWS namespace for AWS API stuff. Created test/aws for AWS tests, and moved previous awspc test into it. 2020-02-05 20:08:46 +02:00
James Yonan
e46a3cb53f
copyright : updated to 2016 2020-02-05 20:08:45 +02:00
James Yonan
ee981f0bd3
AWS : added class AwsPCQuery and tests for fetching AWS instance data such as:
1. instanceId
2. region
3. privateIp
4. concurrentConnections
2020-02-05 20:08:45 +02:00
James Yonan
9667cbe3dd
AWS C++: don't hardcode CA in api_ca(), instead return /etc/ssl/certs/ca-certificates.crt
Signed-off-by: James Yonan <james@openvpn.net>
2020-02-05 20:08:44 +02:00
James Yonan
203b833b92
copyright: updated to 2017
Signed-off-by: James Yonan <james@openvpn.net>
2020-02-05 20:08:43 +02:00
James Yonan
4eb87ef38e
AWS: created mini-SDK for VPC routing API. 2020-02-05 20:08:43 +02:00
James Yonan
b87d69ec32
WS::ClientSet: HTTP persistence refactor
HTTP persistence across transaction sets can now be
simplified using assign_http_state()

Signed-off-by: James Yonan <james@openvpn.net>
2020-02-05 20:08:43 +02:00
James Yonan
8dd3c8fa9c
AWS: increase max_retries to 10 (from 5) and decrease retry delay to 1 sec (from 5)
Signed-off-by: James Yonan <james@openvpn.net>
2020-02-05 20:08:42 +02:00
James Yonan
2a3be2fc87
AWS::HTTPContext: don't enable SSLConst::LOG_VERIFY_STATUS unless debug_level >= 2
Signed-off-by: James Yonan <james@openvpn.net>
2020-02-05 20:08:41 +02:00
James Yonan
8d621c18e9
AWS::HTTPContext: increase frame size to 2048 (from 1024)
Signed-off-by: James Yonan <james@openvpn.net>
2020-02-05 20:08:41 +02:00
James Yonan
5ca8077934
copyright: updated to 2017
Signed-off-by: James Yonan <james@openvpn.net>
2020-02-05 20:08:40 +02:00
James Yonan
030b65a0cd
AWS: created mini-SDK for VPC routing API. 2020-02-05 20:08:39 +02:00
Lev Stipakov
99d4fd2b85
aws: support for temporary credentials
- add optional token parameter, which is required when
using temporary credentials

 - add optional role parameter to fetch
temporary credentials

 - make route API param more fine grained

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2020-02-05 20:08:36 +02:00
Lev Stipakov
de91d4ad73
awsroute.hpp: refactor route management API
Signed-off-by: Lev Stipakov <lev@openvpn.net>
2020-02-05 20:08:36 +02:00
Lev Stipakov
bc0c55af81
awsroute.hpp: use refactored TransactionSet API
TransactionSet API was refactored in commit fa35c78.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2020-02-05 20:08:35 +02:00
James Yonan
c60f27cc3b
copyright: updated to 2017
Signed-off-by: James Yonan <james@openvpn.net>
2020-02-05 20:08:35 +02:00
James Yonan
32875ee9b2
AWS: created mini-SDK for VPC routing API. 2020-02-05 20:08:34 +02:00