207 Commits

Author SHA1 Message Date
cb6e867483 Update the whole project 2024-07-14 21:58:06 +02:00
767cd2d512 Use Ubuntu 24.04 2024-07-14 13:54:03 +02:00
e231e219aa Fix the xor build 2024-07-14 12:50:30 +02:00
0170a5dc76 Use the latest builder 2024-07-14 11:01:23 +02:00
c5694a5672 Update openvpn-xor 2024-07-13 22:31:01 +02:00
c64873d9fc Update vanilla openVPN to 2.6.11 2024-06-20 16:03:42 +02:00
18e09d9658 Do not install glibc 2024-06-05 13:32:59 +02:00
36d4d424f8 install glibc to the final container 2024-05-31 18:26:46 +02:00
db6e07b5c5 Try using sh instead of bash 2024-05-24 16:47:14 +02:00
383dd1b82d Try buidling in Woodpecker CI in matrix 2024-05-24 16:45:13 +02:00
42511439ce Try buidling in Woodpecker CI 2024-05-24 16:28:59 +02:00
5c3f73e8c4 Build newer versions 2024-03-24 11:28:57 +01:00
114050fa99 Get OpenVPN version automatically 2024-02-29 10:29:14 +01:00
0cabb525d4 Get OpenVPN version automatically 2024-02-29 10:25:05 +01:00
cdb94b148a Remove OTP folder 2024-02-27 16:48:21 +01:00
79bfbcc8bd Renove env debug 2024-02-27 16:42:40 +01:00
c827972079 Add build args support 2024-02-27 16:40:29 +01:00
24fb1546b7 Debug 2024-02-27 16:33:51 +01:00
e1071ce9d8 Debug 2024-02-27 16:32:03 +01:00
2fb97bc8d9 Debug 2024-02-27 16:30:02 +01:00
0f4a57694b Try newer build strategy 2024-02-27 16:28:38 +01:00
88edadf5eb Update the version in CI 2024-02-19 15:15:59 +01:00
d8408f498e Update OpenVPN and Tunnelblick versions 2024-02-19 14:46:12 +01:00
c3297b38e9 Update XORed vpn to 2.6.8 2024-01-01 10:56:33 +01:00
cdda2fb983 Trigger build 2023-12-25 19:32:06 +01:00
2df2ec12e8 chore: Keep versions up-to-date 2023-12-25 19:31:23 +01:00
b48a954ab8 Build OpenVPN 2.6.8 2023-11-22 07:29:03 +01:00
0110830c45 Build OpenVPN 2.5.7 2023-11-22 07:27:26 +01:00
61c8a596c4 Build OpenVPN 2.5.6 2023-11-22 07:23:29 +01:00
51c1375013 Remove the broken tag from values 2023-10-23 08:10:30 +02:00
e58669a0ee Set proper values insted of test ones 2023-10-23 08:01:37 +02:00
caba35b2ce Fix the chart and add basic tests 2023-10-23 07:51:38 +02:00
22338d31aa Add workdir to containers 2023-10-22 20:12:18 +02:00
926692d077 Fix image tags 2023-08-24 09:22:18 +02:00
92ed817077 Upgrade Tunnelblick to v4.0.0beta08 2023-08-24 08:55:32 +02:00
b7280be38d Upgrade Tunnelblick to v4.0.0 2023-08-24 08:46:07 +02:00
6d8e8cd5d9 Downgrade versions of openvpn and tunnelblick 2023-08-24 08:18:03 +02:00
2ec840ff63 Take over the project
I've decided to maintain the project myself now, so I've forked it and
create a drone pipeline to push image to my registry
2023-08-18 17:18:48 +02:00
6a86b23ed8 Update ovpn_revokeclient 2022-06-07 16:40:54 -07:00
cd12942dc0 Merge pull request #31 from lawtancool/renovate/ubuntu-18.04
Update ubuntu:18.04 Docker digest to 9bc830a
2021-08-31 09:21:09 -07:00
e6f7ea11cd Update ubuntu:18.04 Docker digest to 9bc830a 2021-08-31 02:51:49 +00:00
ddc4a38eb8 Merge pull request #30 from lawtancool/renovate/ubuntu-18.04
Update ubuntu:18.04 Docker digest to 7bd7a9c
2021-08-08 19:54:03 -07:00
fab100eb0f Update ubuntu:18.04 Docker digest to 7bd7a9c 2021-07-27 00:07:00 +00:00
188206b842 Update to OpenVPN 2.5.3 2021-07-06 19:33:09 -07:00
eacfe8ede7 Merge pull request #29 from lawtancool/renovate/ubuntu-18.04
Update ubuntu:18.04 Docker digest to 139b384
2021-07-05 17:53:42 -07:00
64f9b5fe8b Update ubuntu:18.04 Docker digest to 139b384 2021-06-18 00:33:26 +00:00
3f19c6301e Merge pull request #28 from lawtancool/renovate/ubuntu-18.04
Update ubuntu:18.04 Docker digest to 67b730e
2021-05-27 17:02:05 -07:00
a29488cfc5 Update ubuntu:18.04 Docker digest to 67b730e 2021-05-27 14:08:30 +00:00
7004498a41 Merge pull request #27 from lawtancool/renovate/ubuntu-18.04
Update ubuntu:18.04 Docker digest to 0491977
2021-05-19 23:02:52 -07:00
d67cfcb065 Update ubuntu:18.04 Docker digest to 0491977 2021-05-20 00:44:00 +00:00
ea3dda185b Merge pull request #21 from lawtancool/renovate/docker-ubuntu-18.04
Update ubuntu:18.04 Docker digest to 538529c
2021-04-23 17:30:28 -07:00
0617e24d75 Update ubuntu:18.04 Docker digest to 538529c 2021-04-24 00:13:55 +00:00
345134be4f Merge pull request #20 from lawtancool/renovate/docker-ubuntu-18.04
Update ubuntu:18.04 Docker digest to 4bc3ae6
2021-03-03 22:47:44 -08:00
d888f61366 Update ubuntu:18.04 Docker digest to 4bc3ae6 2021-03-04 05:39:00 +00:00
104c772aff Merge pull request #19 from lawtancool/renovate/docker-ubuntu-18.04
Update ubuntu:18.04 Docker digest to ea188fd
2021-01-31 11:23:52 -08:00
96ee6ecf99 Update ubuntu:18.04 Docker digest to ea188fd 2021-01-27 06:41:04 +00:00
5142fc8a52 Merge pull request #18 from lawtancool/renovate/docker-ubuntu-18.04
Update ubuntu:18.04 Docker digest to 2aeed98
2021-01-20 21:25:40 -08:00
6ebdc89ba7 Update ubuntu:18.04 Docker digest to 2aeed98 2021-01-21 04:54:53 +00:00
95cc4e84f8 Update README with 2.5.0 2021-01-13 10:19:28 -08:00
35347e8c6a Update to OpenVPN 2.5.0 2021-01-10 11:33:27 -08:00
2bb96ab343 Merge pull request #17 from lawtancool/renovate/docker-ubuntu-18.04
Update ubuntu:18.04 Docker digest to a7fa45f
2020-11-26 13:31:43 -08:00
7ff518d4a4 Update ubuntu:18.04 Docker digest to a7fa45f 2020-11-25 23:37:36 +00:00
97598a253c Merge pull request #16 from lawtancool/renovate/docker-ubuntu-18.04
Update ubuntu:18.04 Docker digest to 45c6f8f
2020-09-26 15:47:45 -07:00
eeb8850c5e Update ubuntu:18.04 Docker digest to 45c6f8f 2020-09-25 23:40:31 +00:00
40d5f604da Merge pull request #15 from lawtancool/renovate/docker-ubuntu-18.04
Update ubuntu:18.04 Docker digest to 6654ae9
2020-09-18 20:44:28 -07:00
442dc58dd5 Update ubuntu:18.04 Docker digest to 6654ae9 2020-09-17 00:13:34 +00:00
83a1827fb1 Merge pull request #11 from lawtancool/renovate/docker-ubuntu-18.04
Update ubuntu:18.04 Docker digest to d1bf40f
2020-08-23 20:34:33 -07:00
5fd1bc03a1 Update ubuntu:18.04 Docker digest to d1bf40f 2020-08-24 02:10:17 +00:00
a2f837a03b fix tunnelblick directory 2020-08-23 17:12:04 -07:00
0eecda5ac5 Update to OpenVPN 2.4.9 2020-08-10 17:59:45 -07:00
ac15193e2e Create anchore-analysis.yml 2020-08-10 15:39:50 -07:00
0f67f3aa27 Merge pull request #10 from lawtancool/renovate/docker-ubuntu-18.04
Update ubuntu:18.04 Docker digest to 767eea1
2020-07-24 14:49:55 -07:00
94ea080477 Update ubuntu:18.04 Docker digest to 767eea1 2020-07-24 15:41:55 +00:00
6a4af61b94 Merge pull request #9 from lawtancool/renovate/docker-ubuntu-18.04
Update ubuntu:18.04 Docker digest to 3013b0d
2020-07-07 16:02:52 -07:00
2be3f8638b Update ubuntu:18.04 Docker digest to 3013b0d 2020-07-07 22:36:01 +00:00
326371228b Merge pull request #8 from lawtancool/renovate/docker-ubuntu-18.04
Update ubuntu:18.04 Docker digest to c32bd2e
2020-07-07 15:35:46 -07:00
6d6776835c Update ubuntu:18.04 Docker digest to c32bd2e 2020-07-01 04:53:21 +00:00
ecbecd6c3b delete unnessesary source files from image 2020-03-26 09:47:36 -07:00
ec5ae54e21 add aarch64 qemu for arm64v8 build 2020-03-26 08:26:15 -07:00
13e3e0d651 attempt to fix arm builds 2020-03-25 21:30:10 -07:00
767ce4f62b ubuntu is not available for arm32v6 2020-03-25 21:26:47 -07:00
d2042eea06 add docker hub arm build capability 2020-03-25 21:00:04 -07:00
68b33034f2 add ARM arch dockerfiles 2020-03-25 20:43:36 -07:00
1c6352d100 Merge pull request #5 from lawtancool/renovate/docker-ubuntu-18.04
Update ubuntu:18.04 Docker digest to e5dd9db
2020-03-20 21:24:37 -07:00
3c86360dcd Update ubuntu:18.04 Docker digest to e5dd9db 2020-03-20 21:31:10 +00:00
da174f90e7 Merge pull request #4 from lawtancool/renovate/docker-ubuntu-18.04
Update ubuntu:18.04 Docker digest to 0925d08
2020-02-21 21:17:26 -08:00
9b23df2a6a change server config to tls-crypt instead of tls-auth 2020-02-21 21:16:30 -08:00
b6de5e4a40 change client config to use tls-crypt instead of tls-auth 2020-02-21 21:15:32 -08:00
e70ff1b411 Update ubuntu:18.04 Docker digest to 0925d08 2020-02-21 23:48:09 +00:00
692d5cf54b Merge pull request #3 from lawtancool/renovate/docker-ubuntu-18.04
Update ubuntu:18.04 Docker digest to bc02586
2020-02-11 22:32:13 -08:00
3539cbef73 Update ubuntu:18.04 Docker digest to bc02586 2020-01-16 02:50:25 +00:00
72ce7bb26d fix digest 2019-11-29 21:06:38 -08:00
99233442a2 pin ubuntu image to latest amd64 digest for renovate 2019-11-29 21:04:09 -08:00
43a387d190 Create renovate.json 2019-11-29 20:56:39 -08:00
4463d3fb6f add macOS client 2019-11-17 17:16:54 -08:00
3492009626 add clients with support for obfuscation 2019-11-17 17:16:17 -08:00
738428e544 fix tunnelblick source path again 2019-11-15 20:19:11 -08:00
f59bc9ec15 fix tunnelblick source path 2019-11-15 20:04:36 -08:00
5da288407f update maintainer 2019-11-15 19:49:39 -08:00
7a2f265034 update to openvpn 2.4.8 2019-11-15 19:49:14 -08:00
44f6a7e88b more README.md updates 2019-06-24 20:28:57 -07:00
7ceac7abe4 Update README.md 2019-06-24 20:19:12 -07:00
dbc54eb880 remove x509-types copying from ovpn_genclientcert 2019-06-22 21:51:41 -07:00
de943f0b06 update README.md with ovpn_genclientcert notes 2019-06-22 21:41:31 -07:00
3351f38155 Create ovpn_genclientcert 2019-06-22 21:38:15 -07:00
af3b10e731 fix easyrsa path part 2 2019-06-21 22:34:34 -07:00
83d7af491a fix easyrsa path 2019-06-21 22:34:11 -07:00
dff16d9a4f export EASYRSA="EasyRSA-unix-v3.0.6/" 2019-06-21 22:33:08 -07:00
4afd4c1f90 bump to EasyRSA-unix-v3.0.6 2019-06-21 22:22:05 -07:00
951b98d758 clean up x509-types folder 2019-06-21 21:55:28 -07:00
33e5786326 fix unknown key type server" error 2019-06-21 21:55:01 -07:00
d34995122b add iptables 2019-06-21 21:48:54 -07:00
971dbb4bb5 fix EASYRSA_SSL_CONF 2019-06-21 21:37:35 -07:00
a0fc7f8288 fix easyrsa The OpenSSL config file cannot be found 2019-06-21 21:10:55 -07:00
bc8c2bc3fe fix easyrsa pathing part 2 2019-06-21 20:54:11 -07:00
10ae840c31 fix easyrsa path 2019-06-21 20:53:24 -07:00
42ec170420 add note about removing easyrsa after finishing 2019-06-21 20:19:22 -07:00
ff3a97062b cleanup EasyRSA once we're done 2019-06-21 20:17:01 -07:00
a3ec8a4bcf download easyrsa in pki generation script
because ubuntu doesn't have it on CLI
2019-06-21 20:12:59 -07:00
26a5f0bfb7 add easy-rsa package
needed for pki generation
2019-06-21 19:42:33 -07:00
095a9a11a4 disable systemd in configure 2019-06-21 19:06:59 -07:00
19b4021f3e expose tcp as well 2019-06-21 19:01:42 -07:00
e858cb5a33 add libsystemd-daemon-dev
./configure seemed to need it
2019-06-21 19:00:35 -07:00
3f057f93b1 change to openvpn 2.4.7
because tunnelblick removed 2.4.6 patches in favor of 2.4.7
2019-06-21 18:51:39 -07:00
2975062a3f try removing resolvconf
because it doesn't install properly during the docker image build
2019-06-21 18:43:18 -07:00
0f708e5e30 add -y to apt-get install 2019-06-21 18:35:19 -07:00
a53bd0ca62 Update Dockerfile 2019-06-21 18:26:57 -07:00
79717903fa Fix indents in "quick start" (#454)
* fix indents in "quick start"

no more spaces before an command
2019-02-11 08:04:35 -08:00
47746e1bcb Merge pull request #418 from darkmattercoder/patch-extended-clientstatus
extended client status for EXPIRED or other errors
2019-01-22 22:27:09 -08:00
04df4789fb Merge pull request #436 from kunnix/patch-1
Update docker-openvpn@.service (docker.socket)
2019-01-22 22:24:19 -08:00
556c28fd15 Merge pull request #449 from rowanruseler/master
replaced 404 github link
2019-01-22 22:21:18 -08:00
ec6549238a replaced 404 github link 2019-01-22 11:39:54 +01:00
e83f0118e0 Merge pull request #446 from vansickle/patch-1
Update docker-compose debugging tips to include port publishing
2019-01-18 12:53:28 -08:00
82dfe9cabd Update docker-compose debugging tips to include port publishing
According to the documentation docker-compose run command does not create any of the ports specified in the service configuration. So published ports should be specified in run command, otherwise you wouldn't be able to connect to the openvpn server.
2019-01-18 17:35:09 +03:00
bab729e2e4 Update docker-openvpn@.service (docker.socket)
Since version 1.12, Docker removed `docker.socket` <https://docs.docker.com/release-notes/docker-engine/>

The problem was already present on RPM systems (e.g. RHEL, Fedora, CentOS), and now also seems to affect Debian 9 (Stretch).

This change replaces `docker.socket` by `docker.service`.

It solves this problem:

```
> systemctl start docker-openvpn@.service
Failed to start docker-openvpn@.service: Unit docker.socket not found.
```

Related issues:

 - <https://github.com/kylemanna/docker-openvpn/issues/280>
 - <https://github.com/kylemanna/docker-openvpn/pull/286>
2018-11-08 11:24:57 +01:00
387d39e5d7 Merge pull request #426 from rca/patch-1
Update kernel "SubmittingPatches" link
2018-10-09 22:40:10 -07:00
2f3f99bc22 Use html version of SubmittingPatches URL 2018-10-10 00:14:53 -04:00
f856ee6a52 Update kernel "SubmittingPatches" link 2018-10-09 08:05:00 -04:00
3771097bc9 corrected the output line, was accidentially wrong 2018-08-30 17:08:04 +02:00
ea19fbe932 extended client status for EXPIRED or other errors 2018-09-01 15:40:38 +02:00
cf136d40df README: Add Anchore Image Overview
* Adds a handy security fix.
2018-08-21 10:27:21 -07:00
83b939456e Merge pull request #400 from krlmlr/patch-1
README: Avoid logging for transient containers
2018-06-08 06:12:32 -07:00
5b2f6033c3 Avoid log driver for transient containers 2018-06-08 13:58:16 +02:00
73f8b02172 Merge pull request #383 from DZamataev/master
[bug fix] removes pushing 'comp-lzo' when it is enabled to avoid issues on Android
2018-05-05 19:44:40 -07:00
49d36c2d64 implements setting 'comp-lzo no' on server conf by default 2018-05-03 15:19:02 +03:00
e1bd5b6450 removes pushing 'comp-lzo' when it is enabled 2018-05-01 21:04:31 +03:00
2b8a82ab4a Merge pull request #382 from SizL75/patch-1
fixed typo
2018-04-29 15:59:16 -07:00
092affef43 fixed type
missing space in line 372
2018-04-29 18:15:52 +02:00
5138981623 Merge pull request #380 from DZamataev/master
[bug fix] pushing comp-lzo setting to avoid error
2018-04-28 12:21:13 -07:00
f75f2e17a3 implements pushing comp-lzo setting 2018-04-27 14:34:29 +03:00
23120e4757 Merge pull request #361 from fossabot/master
Add license scan report and status
2018-03-15 14:04:44 -07:00
02e92db6bd Add license scan report and status
Signed-off-by: fossabot <badges@fossa.io>
2018-03-15 13:56:02 -07:00
d5497ba74a Merge pull request #351 from w2ak/master
ovpn_getclient: key-direction before tls-auth
2018-01-04 23:18:36 -08:00
26589a118e [ovpn_getclient] key-direction before tls-auth
NetworkManager seems to be ignoring the `key-direction` directive when
it is after the `tls-auth` key, leading to issues as #268.

Signed-off-by: w2ak <w2ak@users.noreply.github.com>
2018-01-04 19:10:46 +01:00
30fcd3c6da Merge pull request #348 from miesgre/fix-genconfig-arm
Fix ovpn_genconfig script to work in arm architecture
2017-12-22 13:51:27 -08:00
00ec5214e0 Fix ovpn_genconfig to work in arm architecture 2017-12-22 14:29:57 +01:00
fd8daa133a Merge pull request #331 from buchdag/patch-1
Add port sharing example to tcp doc
2017-11-23 14:03:51 -08:00
7b181c05d5 Add port sharing example to tcp doc 2017-11-23 21:41:34 +01:00
054a60c32d Merge pull request #325 from Silex/master
Fix outdated docs.
2017-11-01 20:11:02 -07:00
391f7e0b2f Fix outdated docs. 2017-11-01 17:30:54 +01:00
e82c2ce530 Merge pull request #324 from cglewis/master
MAINTAINER is deprecated, using LABEL now
2017-10-31 22:30:09 -07:00
d7cf0c7e93 MAINTAINER is deprecated, using LABEL now 2017-10-31 20:12:28 -07:00
727231444b Merge pull request #321 from Silex/patch-1
Fix typos
2017-10-22 20:05:35 -07:00
0686b100b1 Fix typos 2017-10-20 14:35:40 +02:00
83d61c7c18 Merge pull request #306 from andrewrembrandt/patch-1
Typo/outdated edit config command?
2017-08-12 06:26:45 -07:00
493865f441 Typo/outdated edit config command?
Looks like this was written for an earlier iteration?
2017-08-11 13:12:57 +01:00
84c87f5f7f Merge pull request #294 from mypetyak/systemd/capabilities
systemd: reduce container privilege by whitelisting NET_ADMIN capability
2017-07-10 22:23:33 -07:00
9f1ae1b989 Merge pull request #293 from mypetyak/docs/escape_contributing_markdown
docs: properly escape CONTRIBUTING markdown
2017-07-10 22:16:57 -07:00
8f09769fdd systemd: reduce container privilege by whitelisting NET_ADMIN capability 2017-07-10 20:10:39 -07:00
571e181152 docs: properly escape CONTRIBUTING markdown 2017-07-10 20:06:05 -07:00
925b08fec4 Merge pull request #283 from buchdag/genconfig-fix
Fix ovpn_genconfig repeatability issue
2017-07-08 11:06:36 -07:00
7a29e8e39b Extra client config is now an array 2017-06-21 02:21:52 +02:00
16fbc4019d Fix ovpn_genconfig for repeatability 2017-06-21 02:21:52 +02:00
63a2449705 Add test for ovpn_genconfig repeatability 2017-06-21 01:03:49 +02:00
1b8374f818 Merge pull request #281 from buchdag/crl-expire
Defaults easy_rsa CRL next update to 3650 days
2017-06-17 09:15:27 -07:00
8d7bc7e2c5 Set CRL next update to 3650 days 2017-06-17 13:17:20 +02:00
e30ee8eecf Add CRL next update test 2017-06-17 13:17:08 +02:00
e00a72a3f6 Dockerfile: master branch follows alpine:latest
The master branch will follow alpine:latest.  See `openvpn-2.x` branches
for more stability.

Related #267
2017-05-26 12:25:43 -07:00
d974c0ac6a README: Mention passphrase prompt and systemd init
* Enhance the documentation to mention that user interaction is
  necessary during the `ovpn_initpki`.
* Re-arrange the next steps part to point people to systemd init as well
  as docs directory.

Closes #266
2017-05-20 08:44:22 -07:00
c0ed8d468d Dockerfile: Drop edge/community for google-authenticator
* Use the primary repository now that google-authenticator is available
  from alpine:v3.5.

Related to #262
2017-05-17 09:27:30 -07:00
2a9059aa36 tests: Clean-up client + conf_options
Clean-up the mess that was here.  It's less error prone, shorter and
easier to read.
2017-05-13 10:52:47 -07:00
074a07e40e genconfig: Fix missing MTU required argument
This must have beeen broken for a long time.  Test case added to prevent
it from breaking again.

Closes #259
2017-05-13 09:50:18 -07:00
8c9d88b316 tests: client: Add client config test suite
* Test the client configuration to detect breakages
2017-05-13 09:50:18 -07:00
78d612d181 Merge pull request #253 from chepurko/patch-1 2017-05-11 11:21:14 -07:00
6bff62eb79 Dockerfile: Swtich from dl-4 to dl-cdn.alpinelinux.org
* At the time of this commit dl-4.alpinelinux.org was unreachable.
* Switch to the CDN instead of some hardcoded server.
2017-05-11 11:20:40 -07:00
8f2f27486c Add quoting into test.sh push options. 2017-05-11 10:55:46 -07:00
3ee5479d78 Push options need to be quoted.
Move the implementation to process_push_config.
2017-05-11 10:55:46 -07:00
909744dd78 Merge pull request #251 from buchdag/buchdag-revoke1
Fix certificate revocation
2017-05-10 09:37:03 -07:00
5aea8b914c Update documentation
Add ovpn_revokeclient usage to client.md and docker-compose.md
2017-05-10 18:08:11 +02:00
a091bef13b Create a script to handle client revocation
This script revoke the certificate corresponding to the commonName passed as first parameter, generate a new CRL, copies it to /etc/openvpn, make it readable by OpenVPN and optionally remove the crt, key and req file corresponding to the revoked certificate using "remove" as second parameter (removal of those files are required to generate a new client certificate using the revoked certificate's CN).
2017-05-10 18:08:11 +02:00
59644d953d Replace hardlinking of crl.pem with a copy
easyrsa gen-crl does not modify the crl.pem in place but rather remove the old file and create a new one, which means any hardlink to it will get broken again at each invocation of easyrsa gen-crl.

If hardlink to this file is not going to work anyway and we still need it to be readable by OpenVPN, we're better off copying it and chmod-ing it every time a new one is detected on container start, using the conditional expression file1 -nt file2.
2017-05-10 18:08:11 +02:00
dcf3791d54 Generate a CRL during PKI initialization 2017-05-10 18:08:11 +02:00
76546e1823 Add client revocation test 2017-05-10 18:08:11 +02:00
f996bbaa8e README: Clarify volume naming convention
* Use a better default that works with systemd service out of the box.
* Update upstart init script to follow convention.
2017-05-10 08:14:51 -07:00
861ed05c48 Merge pull request #254 from buchdag/buchdag-systemd.md
Clarify and complete systemd.md
2017-05-06 07:04:18 -07:00
ce690e5ab1 ovpn_run: Explicitly enable ipv6
On a recent build I ran in to the following error messages:

    Wed May  3 14:31:43 2017 /sbin/ip -6 addr add 2001:db8:0:4::1/64 dev tun0
    Wed May  3 14:31:43 2017 Linux ip -6 addr add failed: external program exited with error status: 2

This appears to be do to the fact that somewhere something defaulted the
kernel in the container to disable IPv6.  Not sure if this is my host or
the docker daemon.  Re-enable it explicitly for now until Docker gets
it's IPv6 act together.
2017-05-03 07:48:15 -07:00
e4821ec709 Clarify and complete systemd.md 2017-05-02 22:24:37 +02:00
808e2448b1 Merge pull request #244 from DerEnderKeks/patch-1
Removed double entry
2017-05-02 10:48:14 -07:00
fe2cdebea2 Removed double entry
the removed line contained the same option as line 63
2017-03-25 19:41:31 +01:00
892a3c9a1c Merge pull request #234 from slamont/master
Add an option for setting different values for keepalive
2017-03-09 20:30:49 -08:00
a3c96bc881 Add test for keepalive 2017-03-09 20:58:46 -05:00
22fcaf9477 Add configuration for keepalive
* Add parameter to disable the push of block-outside-dns
* -d should really do what it was supposed to do
* Fix problem where comp-lzo would always be set regardless of the parameter
2017-03-09 20:35:52 -05:00
d454a20e80 Merge pull request #231 from mediatemple/only_block_when_road_warrior
Only block external dns when default route is pushed
2017-03-07 16:24:34 -08:00
c8ba567333 only block external dns when default route is pushed 2017-03-07 23:21:17 +00:00
21ae2fcef4 fix block-external-dns tests 2017-03-07 23:20:50 +00:00
24944b0a11 Merge pull request #226 from vielmetti/patch-1
Create Dockerfile.aarch64
2017-02-24 09:06:58 -08:00
b74cbd5c74 Create Dockerfile.aarch64
New Dockerfile to support aarch64 (ARMv8, arm64).
2017-02-23 13:59:43 -05:00
36 changed files with 808 additions and 443 deletions

View File

@ -1,33 +0,0 @@
# Disallowing packages: openvpn
# If you require these packages, please review the package approval process at: https://github.com/travis-ci/apt-package-whitelist#package-approval-process
#addons:
# apt:
# sources:
# - ubuntu-toolchain-r-test
# packages:
# - openvpn
services:
- docker
before_install:
- docker --version
install:
- git clone https://github.com/docker-library/official-images.git official-images
# Assist with ci test debugging:
# - DEBUG=1
before_script:
- image="kylemanna/openvpn"
- docker build -t "$image" .
- docker inspect "$image"
- docker run --rm "$image" openvpn --version || true # why does it return 1?
- docker run --rm "$image" openssl version
script:
- official-images/test/run.sh "$image"
- test/run.sh "$image"
after_script:
- docker images

34
.woodpecker.yaml Normal file
View File

@ -0,0 +1,34 @@
---
when:
event:
- push
branch:
- main
matrix:
TARGET:
- openvpn_xor
- openvpn
steps:
build-${TARGET}:
name: Build ${TARGET}
image: git.badhouseplants.net/badhouseplants/badhouseplants-builder:latest
secrets:
- gitea_token
privileged: true
depends_on: []
backend_options:
kubernetes:
resources:
requests:
memory: 500Mi
cpu: 200m
limits:
memory: 500Mi
cpu: 200m
securityContext:
privileged: true
commands:
- source ./env/${TARGET}.env
- ./scripts/$SCRIPT

View File

@ -25,11 +25,11 @@ In an effort to not repeat bugs (and break less popular features), unit tests ar
The style of the repo follows that of the Linux kernel, in particular:
* Pull requests should be rebased to small atomic commits so that the merged history is more coherent
* The subject of the commit should be in the form "<subsystem>: <subject>"
* The subject of the commit should be in the form "`<subsystem>: <subject>`"
* More details in the body
* Match surrounding coding style (line wrapping, spaces, etc)
More details in the [SubmittingPatches](https://www.kernel.org/doc/Documentation/SubmittingPatches) document included with the Linux kernel. In particular the following sections:
More details in the [SubmittingPatches](https://www.kernel.org/doc/html/latest/process/submitting-patches.html) document included with the Linux kernel. In particular the following sections:
* `2) Describe your changes`
* `3) Separate your changes`

View File

@ -1,31 +0,0 @@
# Original credit: https://github.com/jpetazzo/dockvpn
# Smallest base image
FROM alpine:3.5
MAINTAINER Kyle Manna <kyle@kylemanna.com>
RUN echo "http://dl-4.alpinelinux.org/alpine/edge/community/" >> /etc/apk/repositories && \
echo "http://dl-4.alpinelinux.org/alpine/edge/testing/" >> /etc/apk/repositories && \
apk add --update openvpn iptables bash easy-rsa openvpn-auth-pam google-authenticator pamtester && \
ln -s /usr/share/easy-rsa/easyrsa /usr/local/bin && \
rm -rf /tmp/* /var/tmp/* /var/cache/apk/* /var/cache/distfiles/*
# Needed by scripts
ENV OPENVPN /etc/openvpn
ENV EASYRSA /usr/share/easy-rsa
ENV EASYRSA_PKI $OPENVPN/pki
ENV EASYRSA_VARS_FILE $OPENVPN/vars
VOLUME ["/etc/openvpn"]
# Internally uses port 1194/udp, remap using `docker run -p 443:1194/tcp`
EXPOSE 1194/udp
CMD ["ovpn_run"]
ADD ./bin /usr/local/bin
RUN chmod a+x /usr/local/bin/*
# Add support for OTP authentication using a PAM module
ADD ./otp/openvpn /etc/pam.d/

0
Makefile.in Normal file
View File

View File

@ -1,46 +1,62 @@
# OpenVPN for Docker
[![Build Status](https://travis-ci.org/kylemanna/docker-openvpn.svg)](https://travis-ci.org/kylemanna/docker-openvpn)
[![Docker Stars](https://img.shields.io/docker/stars/kylemanna/openvpn.svg)](https://hub.docker.com/r/kylemanna/openvpn/)
[![Docker Pulls](https://img.shields.io/docker/pulls/kylemanna/openvpn.svg)](https://hub.docker.com/r/kylemanna/openvpn/)
[![ImageLayers](https://images.microbadger.com/badges/image/kylemanna/openvpn.svg)](https://microbadger.com/#/images/kylemanna/openvpn)
OpenVPN server in a Docker container complete with an EasyRSA PKI CA.
Extensively tested on [Digital Ocean $5/mo node](http://bit.ly/1C7cKr3) and has
a corresponding [Digital Ocean Community Tutorial](http://bit.ly/1AGUZkq).
OpenVPN server in a Docker container complete with an EasyRSA PKI CA, with support for the [Tunnelblick obfuscation patch](https://tunnelblick.net/cOpenvpn_xorpatch.html). Based on [kylemanna's docker-openvpn image](https://github.com/kylemanna/docker-openvpn).
#### Upstream Links
* Docker Registry @ [kylemanna/openvpn](https://hub.docker.com/r/kylemanna/openvpn/)
* GitHub @ [kylemanna/docker-openvpn](https://github.com/kylemanna/docker-openvpn)
* Docker Registry @ [lawtancool/docker-openvpn-xor](https://hub.docker.com/r/lawtancool/docker-openvpn-xor)
* GitHub @ [lawtancool/docker-openvpn-xor](https://github.com/lawtancool/docker-openvpn-xor)
#### Clients with support for the Tunnelblick obfuscation patch
* Windows: https://github.com/lawtancool/openvpn-windows-xor
* Android: https://github.com/lawtancool/ics-openvpn-xor
* macOS: https://tunnelblick.net/
## Quick Start
* Pick a name for the `$OVPN_DATA` data volume container, it will be created automatically.
* Pick a name for the `$OVPN_DATA` data volume container. It's recommended to
use the `ovpn-data-` prefix to operate seamlessly with the reference systemd
service. Users are encourage to replace `example` with a descriptive name of
their choosing.
OVPN_DATA="ovpn-data"
OVPN_DATA="ovpn-data-example"
* Initialize the `$OVPN_DATA` container that will hold the configuration files and certificates
* Initialize the `$OVPN_DATA` container that will hold the configuration files
and certificates. The container will prompt for a passphrase to protect the
private key used by the newly generated certificate authority.
docker volume create --name $OVPN_DATA
docker run -v $OVPN_DATA:/etc/openvpn --rm kylemanna/openvpn ovpn_genconfig -u udp://VPN.SERVERNAME.COM
docker run -v $OVPN_DATA:/etc/openvpn --rm -it kylemanna/openvpn ovpn_initpki
docker run -v $OVPN_DATA:/etc/openvpn --log-driver=none --rm lawtancool/docker-openvpn-xor ovpn_genconfig -u udp://VPN.SERVERNAME.COM
docker run -v $OVPN_DATA:/etc/openvpn --log-driver=none --rm -it lawtancool/docker-openvpn-xor ovpn_initpki
* Start OpenVPN server process
docker run -v $OVPN_DATA:/etc/openvpn -d -p 1194:1194/udp --cap-add=NET_ADMIN kylemanna/openvpn
docker run -v $OVPN_DATA:/etc/openvpn -d -p 1194:1194/udp --cap-add=NET_ADMIN lawtancool/docker-openvpn-xor
* Generate a client certificate without a passphrase
docker run -v $OVPN_DATA:/etc/openvpn --rm -it kylemanna/openvpn easyrsa build-client-full CLIENTNAME nopass
docker run -v $OVPN_DATA:/etc/openvpn --log-driver=none --rm -it lawtancool/docker-openvpn-xor ovpn_genclientcert CLIENTNAME nopass
* Retrieve the client configuration with embedded certificates
docker run -v $OVPN_DATA:/etc/openvpn --rm kylemanna/openvpn ovpn_getclient CLIENTNAME > CLIENTNAME.ovpn
docker run -v $OVPN_DATA:/etc/openvpn --log-driver=none --rm lawtancool/docker-openvpn-xor ovpn_getclient CLIENTNAME > CLIENTNAME.ovpn
## Docker Compose
## Next Steps
### More Reading
Miscellaneous write-ups for advanced configurations are available in the
[docs](docs) folder.
### Systemd Init Scripts
A `systemd` init script is available to manage the OpenVPN container. It will
start the container on system boot, restart the container if it exits
unexpectedly, and pull updates from Docker Hub to keep itself up to date.
Please refer to the [systemd documentation](docs/systemd.md) to learn more.
### Docker Compose
If you prefer to use `docker-compose` please refer to the [documentation](docs/docker-compose.md).
@ -48,7 +64,7 @@ If you prefer to use `docker-compose` please refer to the [documentation](docs/d
* Create an environment variable with the name DEBUG and value of 1 to enable debug output (using "docker -e").
docker run -v $OVPN_DATA:/etc/openvpn -p 1194:1194/udp --privileged -e DEBUG=1 kylemanna/openvpn
docker run -v $OVPN_DATA:/etc/openvpn -p 1194:1194/udp --privileged -e DEBUG=1 lawtancool/docker-openvpn-xor
* Test using a client that has openvpn installed correctly
@ -66,7 +82,7 @@ If you prefer to use `docker-compose` please refer to the [documentation](docs/d
## How Does It Work?
Initialize the volume container using the `kylemanna/openvpn` image with the
Initialize the volume container using the `lawtancool/docker-openvpn-xor` image with the
included scripts to automatically generate:
- Diffie-Hellman parameters
@ -82,11 +98,11 @@ declares that directory as a volume. It means that you can start another
container with the `-v` argument, and access the configuration.
The volume also holds the PKI keys and certs so that it could be backed up.
To generate a client certificate, `kylemanna/openvpn` uses EasyRSA via the
To generate a client certificate, `lawtancool/docker-openvpn-xor` uses EasyRSA via the
`easyrsa` command in the container's path. The `EASYRSA_*` environmental
variables place the PKI CA under `/etc/openvpn/pki`.
Conveniently, `kylemanna/openvpn` comes with a script called `ovpn_getclient`,
Conveniently, `lawtancool/docker-openvpn-xor` comes with a script called `ovpn_getclient`,
which dumps an inline OpenVPN client configuration file. This single file can
then be given to a client for access to the VPN.
@ -152,7 +168,7 @@ OpenVPN with latest OpenSSL on Ubuntu 12.04 LTS).
### It Doesn't Stomp All Over the Server's Filesystem
Everything for the Docker container is contained in two images: the ephemeral
run time image (kylemanna/openvpn) and the `$OVPN_DATA` data volume. To remove
run time image (lawtancool/docker-openvpn-xor) and the `$OVPN_DATA` data volume. To remove
it, remove the corresponding containers, `$OVPN_DATA` data volume and Docker
image and it's completely removed. This also makes it easier to run multiple
servers since each lives in the bubble of the container (of course multiple IPs
@ -174,12 +190,6 @@ of a guarantee in the future.
volume for re-use across containers
* Addition of tls-auth for HMAC security
## Originally Tested On
* Docker hosts:
* server a [Digital Ocean](https://www.digitalocean.com/?refcode=d19f7fe88c94) Droplet with 512 MB RAM running Ubuntu 14.04
* Clients
* Android App OpenVPN Connect 1.1.14 (built 56)
* OpenVPN core 3.0 android armv7a thumb2 32-bit
* OS X Mavericks with Tunnelblick 3.4beta26 (build 3828) using openvpn-2.3.4
* ArchLinux OpenVPN pkg 2.3.4-1
## Differences from kylemanna/openvpn
* Based on Ubuntu instead of Alpine
* Compiles OpenVPN 2.5.0 from source, applying the [Tunnelblick obfuscation patches](https://github.com/Tunnelblick/Tunnelblick/tree/master/third_party/sources/openvpn/openvpn-2.5.0/patches)

View File

@ -1,52 +0,0 @@
# Contributor: Fabio Napoleoni <f.napoleoni@gmail.com>
# Maintainer:
pkgname=google-authenticator
pkgver=20160207
pkgrel=1
pkgdesc="Google Authenticator PAM module"
url="https://github.com/google/google-authenticator"
arch="all"
license="ASL 2.0"
depends=
depends_dev=
makedepends="$depends_dev autoconf automake libtool linux-pam-dev m4 openssl-dev"
install=
subpackages="$pkgname-doc"
source="https://github.com/google/google-authenticator/archive/c0404dcdbda9ab9e4f0b8451ecdd44eee8db2425.zip"
_builddir="$srcdir"/$pkgname-c0404dcdbda9ab9e4f0b8451ecdd44eee8db2425/libpam
prepare() {
local i
cd "$_builddir"
for i in $source; do
case $i in
*.patch) msg $i; patch -p1 -i "$srcdir"/$i || return 1;;
esac
done
}
build() {
cd "$_builddir"
./bootstrap.sh || return 1
./configure \
--build=$CBUILD \
--host=$CHOST \
--prefix=/usr \
--libdir=/lib \
--sysconfdir=/etc \
--mandir=/usr/share/man \
--infodir=/usr/share/info \
|| return 1
make || return 1
}
package() {
cd "$_builddir"
make DESTDIR="$pkgdir" install || return 1
}
md5sums="33d3cbd0488bcb4f50b34b5670deffae c0404dcdbda9ab9e4f0b8451ecdd44eee8db2425.zip"
sha256sums="e32abe693e54195bdb6aca52783e6e1c239e67296876ac59211a59e4608338b8 c0404dcdbda9ab9e4f0b8451ecdd44eee8db2425.zip"
sha512sums="b44a626e6cc5d8e27685f5d39b5d33f49fc7070331db7b458d3ee40723972821bb8ed5458f27a287dc664d162acf1f8f9a36ca3b1bf767f2bbf27d4f538e9872 c0404dcdbda9ab9e4f0b8451ecdd44eee8db2425.zip"

18
bin/ovpn_genclientcert Normal file
View File

@ -0,0 +1,18 @@
#!/bin/bash
#
# Generate a client certificate with EasyRSA
#
if [ "$DEBUG" == "1" ]; then
set -x
fi
CLIENTNAME=$1
PASSWORD=$2
set -e
source "$OPENVPN/ovpn_env.sh"
/usr/share/easy-rsa/easyrsa build-client-full $CLIENTNAME $PASSWORD

View File

@ -7,7 +7,6 @@
TMP_PUSH_CONFIGFILE=$(mktemp -t vpn_push.XXXXXXX)
TMP_ROUTE_CONFIGFILE=$(mktemp -t vpn_route.XXXXXXX)
TMP_EXTRA_CONFIGFILE=$(mktemp -t vpn_extra.XXXXXXX)
TMP_EXTRA_CLIENT_CONFIGFILE=$(mktemp -t vpn_extra_client.XXXXXXX)
#Traceback on Error and Exit come from https://docwhat.org/tracebacks-in-bash/
set -eu
@ -46,7 +45,6 @@ on_exit() {
rm -f $TMP_PUSH_CONFIGFILE
rm -f $TMP_ROUTE_CONFIGFILE
rm -f $TMP_EXTRA_CONFIGFILE
rm -f $TMP_EXTRA_CLIENT_CONFIGFILE
local _ec="$?"
if [[ $_ec != 0 && "${_showed_traceback}" != t ]]; then
traceback 1
@ -95,10 +93,12 @@ usage() {
echo "optional arguments:"
echo " -2 Enable two factor authentication using Google Authenticator."
echo " -a Authenticate packets with HMAC using the given message digest algorithm (auth)."
echo " -b Disable 'push block-outside-dns'"
echo " -c Enable client-to-client option"
echo " -C A list of allowable TLS ciphers delimited by a colon (cipher)."
echo " -d Disable NAT routing and default route"
echo " -d Disable default route"
echo " -D Do not push dns servers"
echo " -k Set keepalive. Default: '10 60'"
echo " -m Set client MTU"
echo " -N Configure NAT to access external server network"
echo " -t Use TAP device (instead of TUN device)"
@ -119,7 +119,7 @@ process_push_config() {
local ovpn_push_config=''
ovpn_push_config="$1"
echo "Processing PUSH Config: '${ovpn_push_config}'"
[[ -n "$ovpn_push_config" ]] && echo "push $ovpn_push_config" >> "$TMP_PUSH_CONFIGFILE"
[[ -n "$ovpn_push_config" ]] && echo "push \"$ovpn_push_config\"" >> "$TMP_PUSH_CONFIGFILE"
}
process_extra_config() {
@ -127,14 +127,6 @@ process_extra_config() {
ovpn_extra_config="$1"
echo "Processing Extra Config: '${ovpn_extra_config}'"
[[ -n "$ovpn_extra_config" ]] && echo "$ovpn_extra_config" >> "$TMP_EXTRA_CONFIGFILE"
}
process_extra_client_config() {
local ovpn_extra_config=''
ovpn_extra_config="$1"
echo "Processing Extra Client Config: '${ovpn_extra_config}'"
[[ -n "$ovpn_extra_config" ]] && echo "$ovpn_extra_config" >> "$TMP_EXTRA_CLIENT_CONFIGFILE"
}
if [ "${DEBUG:-}" == "1" ]; then
@ -150,35 +142,52 @@ if [ -z "${EASYRSA_PKI:-}" ]; then
export EASYRSA_PKI="$OPENVPN/pki"
fi
OVPN_ENV=${OPENVPN}/ovpn_env.sh
OVPN_SERVER=192.168.255.0/24
OVPN_AUTH=''
OVPN_CIPHER=''
OVPN_CLIENT_TO_CLIENT=''
OVPN_CN=''
OVPN_COMP_LZO=0
OVPN_DEFROUTE=1
OVPN_NAT=0
OVPN_DNS=1
OVPN_DEVICE="tun"
OVPN_DEVICEN=0
OVPN_DNS_SERVERS=("8.8.8.8" "8.8.4.4")
TMP_DNS_SERVERS=()
OVPN_DISABLE_PUSH_BLOCK_DNS=0
OVPN_DNS=1
OVPN_DNS_SERVERS=()
OVPN_ENV=${OPENVPN}/ovpn_env.sh
OVPN_EXTRA_CLIENT_CONFIG=()
OVPN_EXTRA_SERVER_CONFIG=()
OVPN_FRAGMENT=''
OVPN_KEEPALIVE="10 60"
OVPN_MTU=''
OVPN_NAT=0
OVPN_PORT=''
OVPN_PROTO=''
OVPN_PUSH=()
OVPN_ROUTES=()
OVPN_SERVER=192.168.255.0/24
OVPN_SERVER_URL=''
OVPN_TLS_CIPHER=''
OVPN_CIPHER=''
OVPN_AUTH=''
OVPN_EXTRA_CONFIG=''
CUSTOM_ROUTE_CONFIG=''
# Import defaults if present
# Import existing configuration if present
[ -r "$OVPN_ENV" ] && source "$OVPN_ENV"
# Parse arguments
while getopts ":a:e:E:C:T:r:s:du:cp:n:DNmf:tz2" opt; do
while getopts ":a:e:E:C:T:r:s:du:bcp:n:k:DNm:f:tz2" opt; do
case $opt in
a)
OVPN_AUTH="$OPTARG"
;;
e)
process_extra_config "$OPTARG"
mapfile -t TMP_EXTRA_SERVER_CONFIG <<< "$OPTARG"
for i in "${TMP_EXTRA_SERVER_CONFIG[@]}"; do
OVPN_EXTRA_SERVER_CONFIG+=("$i")
done
;;
E)
process_extra_client_config "$OPTARG"
mapfile -t TMP_EXTRA_CLIENT_CONFIG <<< "$OPTARG"
for i in "${TMP_EXTRA_CLIENT_CONFIG[@]}"; do
OVPN_EXTRA_CLIENT_CONFIG+=("$i")
done
;;
C)
OVPN_CIPHER="$OPTARG"
@ -187,26 +196,38 @@ while getopts ":a:e:E:C:T:r:s:du:cp:n:DNmf:tz2" opt; do
OVPN_TLS_CIPHER="$OPTARG"
;;
r)
CUSTOM_ROUTE_CONFIG=1
process_route_config "$OPTARG"
mapfile -t TMP_ROUTES <<< "$OPTARG"
for i in "${TMP_ROUTES[@]}"; do
OVPN_ROUTES+=("$i")
done
;;
s)
OVPN_SERVER=$OPTARG
OVPN_SERVER="$OPTARG"
;;
d)
OVPN_DEFROUTE=0
OVPN_DISABLE_PUSH_BLOCK_DNS=1
;;
u)
OVPN_SERVER_URL=$OPTARG
OVPN_SERVER_URL="$OPTARG"
;;
b)
OVPN_DISABLE_PUSH_BLOCK_DNS=1
;;
c)
OVPN_CLIENT_TO_CLIENT=1
;;
p)
process_push_config "$OPTARG"
mapfile -t TMP_PUSH <<< "$OPTARG"
for i in "${TMP_PUSH[@]}"; do
OVPN_PUSH+=("$i")
done
;;
n)
TMP_DNS_SERVERS+=("$OPTARG")
mapfile -t TMP_DNS_SERVERS <<< "$OPTARG"
for i in "${TMP_DNS_SERVERS[@]}"; do
OVPN_DNS_SERVERS+=("$i")
done
;;
D)
OVPN_DNS=0
@ -214,8 +235,11 @@ while getopts ":a:e:E:C:T:r:s:du:cp:n:DNmf:tz2" opt; do
N)
OVPN_NAT=1
;;
k)
OVPN_KEEPALIVE="$OPTARG"
;;
m)
OVPN_MTU=$OPTARG
OVPN_MTU="$OPTARG"
;;
t)
OVPN_DEVICE="tap"
@ -227,7 +251,7 @@ while getopts ":a:e:E:C:T:r:s:du:cp:n:DNmf:tz2" opt; do
OVPN_OTP_AUTH=1
;;
f)
OVPN_FRAGMENT=$OPTARG
OVPN_FRAGMENT="$OPTARG"
;;
\?)
set +x
@ -247,9 +271,6 @@ done
# Create ccd directory for static routes
[ ! -d "${OPENVPN:-}/ccd" ] && mkdir -p ${OPENVPN:-}/ccd
# if dns servers were not defined with -n, use google nameservers
[ ${#TMP_DNS_SERVERS[@]} -gt 0 ] && OVPN_DNS_SERVERS=("${TMP_DNS_SERVERS[@]}")
# Server name is in the form "udp://vpn.example.com:1194"
if [[ "${OVPN_SERVER_URL:-}" =~ ^((udp|tcp|udp6|tcp6)://)?([0-9a-zA-Z\.\-]+)(:([0-9]+))?$ ]]; then
OVPN_PROTO=${BASH_REMATCH[2]};
@ -262,24 +283,13 @@ else
exit 1
fi
# Apply defaults
# Apply defaults. If dns servers were not defined with -n, use google nameservers
set +u
[ -z "$OVPN_DNS_SERVERS" ] && OVPN_DNS_SERVERS=("8.8.8.8" "8.8.4.4")
[ -z "$OVPN_PROTO" ] && OVPN_PROTO=udp
[ -z "$OVPN_PORT" ] && OVPN_PORT=1194
[ -z "$CUSTOM_ROUTE_CONFIG" ] && process_route_config "192.168.254.0/24"
# Save extra client config from temp file only if temp file is not empty
if [ -s "$TMP_EXTRA_CLIENT_CONFIGFILE" ]; then
OVPN_ADDITIONAL_CLIENT_CONFIG=$(cat $TMP_EXTRA_CLIENT_CONFIGFILE)
fi
export OVPN_SERVER OVPN_ROUTES OVPN_DEFROUTE
export OVPN_SERVER_URL OVPN_ENV OVPN_PROTO OVPN_CN OVPN_PORT
export OVPN_CLIENT_TO_CLIENT OVPN_PUSH OVPN_NAT OVPN_DNS OVPN_MTU OVPN_DEVICE
export OVPN_TLS_CIPHER OVPN_CIPHER OVPN_AUTH
export OVPN_COMP_LZO
export OVPN_OTP_AUTH
export OVPN_FRAGMENT
export OVPN_ADDITIONAL_CLIENT_CONFIG
set -u
[ "${#OVPN_ROUTES[@]}" == "0" ] && [ "$OVPN_DEFROUTE" == "1" ] && OVPN_ROUTES+=("192.168.254.0/24")
# Preserve config
if [ -f "$OVPN_ENV" ]; then
@ -288,17 +298,10 @@ if [ -f "$OVPN_ENV" ]; then
mv "$OVPN_ENV" "$bak_env"
fi
# Like `export | grep OVPN_ > "$OVPN_ENV"` but handles multiline variables
set +u
while read var ; do
eval value=\$$var
if [ -n "$value" ]; then
echo "declare -x $var=\"$value\"" >> "$OVPN_ENV"
else
# Save the current OVPN_ vars to the ovpn_env.sh file
(set | grep '^OVPN_') | while read -r var; do
echo "declare -x $var" >> "$OVPN_ENV"
fi
done < <(export | egrep -o '(OVPN_[^=]+)')
set -u
done
conf=${OPENVPN:-}/openvpn.conf
if [ -f "$conf" ]; then
@ -307,6 +310,13 @@ if [ -f "$conf" ]; then
mv "$conf" "$bak"
fi
# Echo extra client configurations
if [ ${#OVPN_EXTRA_CLIENT_CONFIG[@]} -gt 0 ]; then
for i in "${OVPN_EXTRA_CLIENT_CONFIG[@]}"; do
echo "Processing Extra Client Config: $i"
done
fi
cat > "$conf" <<EOF
server $(getroute $OVPN_SERVER)
verb 3
@ -314,9 +324,9 @@ key $EASYRSA_PKI/private/${OVPN_CN}.key
ca $EASYRSA_PKI/ca.crt
cert $EASYRSA_PKI/issued/${OVPN_CN}.crt
dh $EASYRSA_PKI/dh.pem
tls-auth $EASYRSA_PKI/ta.key
key-direction 0
keepalive 10 60
tls-crypt $EASYRSA_PKI/ta.key
#key-direction 0
keepalive $OVPN_KEEPALIVE
persist-key
persist-tun
@ -330,39 +340,62 @@ user nobody
group nogroup
EOF
#This was in the heredoc, we use the new function instead
if [ "${OVPN_DISABLE_PUSH_BLOCK_DNS}" == "1" ]; then
echo "Disable default push of 'block-outside-dns'"
else
process_push_config "block-outside-dns"
fi
[ -n "$OVPN_TLS_CIPHER" ] && echo "tls-cipher $OVPN_TLS_CIPHER" >> "$conf"
[ -n "$OVPN_CIPHER" ] && echo "cipher $OVPN_CIPHER" >> "$conf"
[ -n "$OVPN_AUTH" ] && echo "auth $OVPN_AUTH" >> "$conf"
[ -n "${OVPN_CLIENT_TO_CLIENT:-}" ] && echo "client-to-client" >> "$conf"
[ -n "${OVPN_COMP_LZO:-}" ] && echo "comp-lzo" >> "$conf"
[ "$OVPN_COMP_LZO" == "1" ] && echo "comp-lzo" >> "$conf"
[ "$OVPN_COMP_LZO" == "0" ] && echo "comp-lzo no" >> "$conf"
[ -n "${OVPN_FRAGMENT:-}" ] && echo "fragment $OVPN_FRAGMENT" >> "$conf"
# Append route commands
if [ ${#OVPN_ROUTES[@]} -gt 0 ]; then
for i in "${OVPN_ROUTES[@]}"; do
process_route_config "$i"
done
echo -e "\n### Route Configurations Below" >> "$conf"
cat $TMP_ROUTE_CONFIGFILE >> "$conf"
fi
# Append push commands
[ "$OVPN_DNS" == "1" ] && for i in "${OVPN_DNS_SERVERS[@]}"; do
process_push_config "dhcp-option DNS $i"
done
# Append route commands
echo -e "\n### Route Configurations Below" >> "$conf"
cat $TMP_ROUTE_CONFIGFILE >> "$conf"
if [ "$OVPN_COMP_LZO" == "0" ]; then
process_push_config "comp-lzo no"
fi
[ ${#OVPN_PUSH[@]} -gt 0 ] && for i in "${OVPN_PUSH[@]}"; do
process_push_config "$i"
done
# Append push commands
echo -e "\n### Push Configurations Below" >> "$conf"
cat $TMP_PUSH_CONFIGFILE >> "$conf"
# Optional OTP authentication support
# Append optional OTP authentication support
if [ -n "${OVPN_OTP_AUTH:-}" ]; then
echo -e "\n\n# Enable OTP+PAM for user authentication" >> "$conf"
echo "plugin /usr/lib/openvpn/plugins/openvpn-plugin-auth-pam.so openvpn" >> "$conf"
echo "reneg-sec 0" >> "$conf"
fi
# Append extra server configurations
if [ ${#OVPN_EXTRA_SERVER_CONFIG[@]} -gt 0 ]; then
for i in "${OVPN_EXTRA_SERVER_CONFIG[@]}"; do
process_extra_config "$i"
done
echo -e "\n### Extra Configurations Below" >> "$conf"
cat $TMP_EXTRA_CONFIGFILE >> "$conf"
fi
set +e

View File

@ -35,7 +35,6 @@ get_client_config() {
client
nobind
dev $OVPN_DEVICE
key-direction 1
remote-cert-tls server
remote $OVPN_CN $OVPN_PORT $OVPN_PROTO"
@ -45,8 +44,9 @@ remote $OVPN_CN $OVPN_PORT $OVPN_PROTO"
if [ "$OVPN_PROTO" == "tcp6" ]; then
echo "remote $OVPN_CN $OVPN_PORT tcp"
fi
echo "$OVPN_ADDITIONAL_CLIENT_CONFIG
"
for i in "${OVPN_EXTRA_CLIENT_CONFIG[@]}"; do
echo "$i"
done
if [ "$mode" == "combined" ]; then
echo "
<key>
@ -58,17 +58,18 @@ $(openssl x509 -in $EASYRSA_PKI/issued/${cn}.crt)
<ca>
$(cat $EASYRSA_PKI/ca.crt)
</ca>
<tls-auth>
#key-direction 1
<tls-crypt>
$(cat $EASYRSA_PKI/ta.key)
</tls-auth>
key-direction 1
</tls-crypt>
"
elif [ "$mode" == "separated" ]; then
echo "
key ${cn}.key
ca ca.crt
cert ${cn}.crt
tls-auth ta.key 1
tls-crypt ta.key
#tls-auth ta.key 1
"
fi
@ -97,7 +98,7 @@ tls-auth ta.key 1
echo "auth-nocache"
fi
if [ -n "$OVPN_COMP_LZO" ]; then
if [ "$OVPN_COMP_LZO" == "1" ]; then
echo "comp-lzo"
fi
@ -124,9 +125,9 @@ case "$parm" in
get_client_config "combined" > "$dir/${cn}-combined.ovpn"
;;
*)
echo "This script can produce the client configuration in to formats:" >&2
echo "This script can produce the client configuration in two formats:" >&2
echo " 1. combined (default): All needed configuration and cryptographic material is in one file (Use \"combined-save\" to write the configuration file in the same path as the separated parameter does)." >&2
echo " 2. separated: Separated files." >&2
echo "Please specific one of those options as second parameter." >&2
echo "Please specify one of those options as second parameter." >&2
;;
esac

View File

@ -15,15 +15,9 @@ source "$OPENVPN/ovpn_env.sh"
# Specify "nopass" as arg[2] to make the CA insecure (not recommended!)
nopass=$1
# Provides a sufficient warning before erasing pre-existing files
easyrsa init-pki
# CA always has a password for protection in event server is compromised. The
# password is only needed to sign client/server certificates. No password is
# needed for normal OpenVPN operation.
easyrsa build-ca $nopass
easyrsa gen-dh
/usr/share/easy-rsa/easyrsa init-pki
/usr/share/easy-rsa/easyrsa build-ca $nopass
/usr/share/easy-rsa/easyrsa gen-dh
openvpn --genkey --secret $EASYRSA_PKI/ta.key
# Was nice to autoset, but probably a bad idea in practice, users should
@ -37,4 +31,7 @@ openvpn --genkey --secret $EASYRSA_PKI/ta.key
#fi
# For a server key with a password, manually init; this is autopilot
easyrsa build-server-full "$OVPN_CN" nopass
/usr/share/easy-rsa/easyrsa build-server-full "$OVPN_CN" nopass
# Generate the CRL for client/server certificates revocation.
/usr/share/easy-rsa/easyrsa gen-crl

View File

@ -15,6 +15,8 @@ cd "$EASYRSA_PKI"
if [ -e crl.pem ]; then
cat ca.crt crl.pem > cacheck.pem
else
cat ca.crt > cacheck.pem
fi
echo "name,begin,end,status"
@ -26,20 +28,27 @@ for name in issued/*.crt; do
name=${name%.crt}
name=${name#issued/}
if [ "$name" != "$OVPN_CN" ]; then
if [ -e crl.pem ]; then
if openssl verify -crl_check -CAfile cacheck.pem $path &> /dev/null; then
# check for revocation or expiration
command="openssl verify -crl_check -CAfile cacheck.pem $path"
result=$($command)
if [ $(echo "$result" | wc -l) == 1 ] && [ "$(echo "$result" | grep ": OK")" ]; then
status="VALID"
else
result=$(echo "$result" | tail -n 1 | grep error | cut -d" " -f2)
case $result in
10)
status="EXPIRED"
;;
23)
status="REVOKED"
;;
*)
status="INVALID"
esac
fi
else
status="VALID"
fi
echo "$name,$begin,$end,$status"
fi
done
if [ -e crl.pem ]; then
# Clean
rm cacheck.pem
fi

62
bin/ovpn_revokeclient Executable file
View File

@ -0,0 +1,62 @@
#!/bin/bash
#
# Revoke a client certificate
#
if [ "$DEBUG" == "1" ]; then
set -x
fi
set -e
if [ -z "$OPENVPN" ]; then
export OPENVPN="$PWD"
fi
if ! source "$OPENVPN/ovpn_env.sh"; then
echo "Could not source $OPENVPN/ovpn_env.sh."
exit 1
fi
if [ -z "$EASYRSA_PKI" ]; then
export EASYRSA_PKI="$OPENVPN/pki"
fi
cn="$1"
parm="$2"
if [ ! -f "$EASYRSA_PKI/private/${cn}.key" ]; then
echo "Unable to find \"${cn}\", please try again or generate the key first" >&2
exit 1
fi
revoke_client_certificate(){
# Download EasyRSA because Ubuntu doesn't have it as a CLI command
/usr/share/easy-rsa/easyrsa revoke "$1"
echo "Generating the Certificate Revocation List :"
/usr/share/easy-rsa/easyrsa gen-crl
cp -f "$EASYRSA_PKI/crl.pem" "$OPENVPN/crl.pem"
chmod 644 "$OPENVPN/crl.pem"
}
remove_files(){
rm -v "$EASYRSA_PKI/issued/${1}.crt"
rm -v "$EASYRSA_PKI/private/${1}.key"
rm -v "$EASYRSA_PKI/reqs/${1}.req"
}
case "$parm" in
"remove")
revoke_client_certificate "$cn"
remove_files "$cn"
;;
"" | "keep")
revoke_client_certificate "$cn"
;;
*)
echo "When revoking a client certificate, this script let you choose if you want to remove the corresponding crt, key and req files." >&2
echo "Pease note that the removal of those files is required if you want to generate a new client certificate using the revoked certificate's CN." >&2
echo " 1. keep (default): Keep the files." >&2
echo " 2. remove: Remove the files." >&2
echo "Please specify one of those options as second parameter." >&2
;;
esac

View File

@ -74,13 +74,14 @@ if [ "$OVPN_DEFROUTE" != "0" ] || [ "$OVPN_NAT" == "1" ] ; then
setupIptablesAndRouting
fi
# Use a hacky hardlink as the CRL Needs to be readable by the user/group
# Use a copy of crl.pem as the CRL Needs to be readable by the user/group
# OpenVPN is running as. Only pass arguments to OpenVPN if it's found.
if [ -r "$EASYRSA_PKI/crl.pem" ]; then
if [ ! -r "$OPENVPN/crl.pem" ]; then
ln "$EASYRSA_PKI/crl.pem" "$OPENVPN/crl.pem"
if [ "$EASYRSA_PKI/crl.pem" -nt "$OPENVPN/crl.pem" ]; then
cp -f "$EASYRSA_PKI/crl.pem" "$OPENVPN/crl.pem"
chmod 644 "$OPENVPN/crl.pem"
fi
if [ -r "$OPENVPN/crl.pem" ]; then
addArg "--crl-verify" "$OPENVPN/crl.pem"
fi
@ -90,6 +91,7 @@ if [ $? = 0 ]; then
# If this fails, ensure the docker container is run with --privileged
# Could be side stepped with `ip netns` madness to drop privileged flag
sysctl -w net.ipv6.conf.all.disable_ipv6=0 || echo "Failed to enable IPv6 support"
sysctl -w net.ipv6.conf.default.forwarding=1 || echo "Failed to enable IPv6 Forwarding default"
sysctl -w net.ipv6.conf.all.forwarding=1 || echo "Failed to enable IPv6 Forwarding"
fi

20
bin/start_openvpn Executable file
View File

@ -0,0 +1,20 @@
#!/usr/bin/env bash
if [ -z "$( ls -A '/opt/data/openvpn' )" ] || [ "${EASY_RSA_REGEN}" == "true" ]; then
rm -rf /opt/data/openvpn/*
# -- It should prepare certs with easy-rsa
/usr/share/easy-rsa/easyrsa init-pki
# -- Currently only no password
/usr/share/easy-rsa/easyrsa build-ca nopass
/usr/share/easy-rsa/easyrsa gen-dh
`unset EASYRSA_REQ_CN && /usr/share/easy-rsa/easyrsa build-server-full server nopass`
# -- Generate the CRL for client/server certificates revocation.
/usr/share/easy-rsa/easyrsa gen-crl
openvpn --genkey tls-crypt-v2-server "pki/private/${EASYRSA_REQ_CN}.pem"
openvpn --genkey secret > "ta.key"
else
echo "Easy RSA config is already prepared, skipping"
fi
cp /opt/data/openvpn/ta.key /etc/openvpn/server
openvpn --config /opt/config/server.conf

View File

@ -0,0 +1,64 @@
FROM ghcr.io/allanger/dumb-downloader as dudo
ARG OPENVPN_VERSION
RUN apt update && apt install gnupg tar -y
RUN mkdir /output
# ------------------------------------------------------
# -- Downlaod OpenVPN
# ------------------------------------------------------
RUN dudo -l "https://keys.openpgp.org/vks/v1/by-fingerprint/F554A3687412CFFEBDEFE0A312F5F7B42F2B01E7" -d security-openvpn-net.asc -p DUMMY
RUN gpg --import security-openvpn-net.asc
RUN dudo -l "https://swupdate.openvpn.org/community/releases/openvpn-{{ version }}.tar.gz.asc" -d /tmp/openvpn.asc -p ${OPENVPN_VERSION}
# ------------------------------------------------------
# -- todo: I should fix it later
# ------------------------------------------------------
# RUN gpg --no-tty --verify /tmp/openvpn.asc
RUN dudo -l "https://swupdate.openvpn.org/community/releases/openvpn-{{ version }}.tar.gz " -d /tmp/openvpn.tar.gz -p ${OPENVPN_VERSION}
RUN tar -xf /tmp/openvpn.tar.gz -C /tmp && rm -f /tmp/openvpn.tar.gz
RUN mv /tmp/openvpn-${OPENVPN_VERSION} /output/openvpn
FROM ubuntu:24.04 as builder
# ------------------------------------------------------
# -- TODO: Define it only once
# ------------------------------------------------------
ARG OPENVPN_VERSION
COPY --from=dudo /output /src
RUN apt-get update &&\
apt-get install -y wget tar unzip build-essential \
libssl-dev iproute2 liblz4-dev liblzo2-dev \
libpam0g-dev libpkcs11-helper1-dev libsystemd-dev \
easy-rsa iptables pkg-config libcap-ng-dev
WORKDIR /src/openvpn
RUN ./configure --disable-systemd --enable-async-push --enable-iproute2
RUN make && make install
RUN mkdir /output
RUN cp $(which openvpn) /output
RUN cp /src/openvpn/sample/sample-config-files/server.conf /output
# ------------------------------------------------------
# -- Final container
# ------------------------------------------------------
FROM ubuntu:24.04
LABEL maintainer="allanger <allanger@badhouseplants.net>"
VOLUME /opt/data/openvpn
WORKDIR /opt/data/openvpn
ENV EASYRSA_BATCH=yes
ENV EASYRSA_REQ_CN=openvpn-server
COPY --from=builder /output/openvpn /src/openvpn
COPY --from=builder /output/server.conf /opt/config/server.conf
# -------------------------------------------------------
# -- Prepare system deps
# -- It's also installing the openvpn package but
# -- it's required for getting dependencies, later
# -- it's rewritten by the binary that from the builder
# -------------------------------------------------------
RUN apt update &&\
apt upgrade -y && \
apt install openvpn easy-rsa -y && \
mv /src/openvpn $(which openvpn)
CMD ["ovpn_run"]
COPY --chmod='755' ./bin /usr/local/bin

View File

@ -0,0 +1,78 @@
FROM ghcr.io/allanger/dumb-downloader as dudo
ARG OPENVPN_VERSION
ARG TUNNELBLICK_VERSION
RUN apt update && apt install gnupg tar -y
RUN mkdir /output
# ------------------------------------------------------
# -- Downlaod OpenVPN
# ------------------------------------------------------
RUN dudo -l "https://keys.openpgp.org/vks/v1/by-fingerprint/F554A3687412CFFEBDEFE0A312F5F7B42F2B01E7" -d security-openvpn-net.asc -p DUMMY
RUN gpg --import security-openvpn-net.asc
RUN dudo -l "https://swupdate.openvpn.org/community/releases/openvpn-{{ version }}.tar.gz.asc" -d /tmp/openvpn.asc -p $OPENVPN_VERSION
# ------------------------------------------------------
# -- I should fix it later
# ------------------------------------------------------
# RUN gpg --no-tty --verify /tmp/openvpn.asc
RUN dudo -l "https://swupdate.openvpn.org/community/releases/openvpn-{{ version }}.tar.gz " -d /tmp/openvpn.tar.gz -p $OPENVPN_VERSION
RUN tar -xf /tmp/openvpn.tar.gz -C /tmp && rm -f /tmp/openvpn.tar.gz
RUN mv /tmp/openvpn-$OPENVPN_VERSION /output/openvpn
# ------------------------------------------------------
# -- Download Tunnelblick
# ------------------------------------------------------
RUN dudo -l "https://github.com/Tunnelblick/Tunnelblick/archive/refs/tags/v{{ version }}.tar.gz" -d /tmp/tunnelblick.tar.gz -p $TUNNELBLICK_VERSION
RUN tar -xf /tmp/tunnelblick.tar.gz -C /tmp && rm -f /tmp/tunnelblick.tar.gz
RUN mv /tmp/Tunnelblick-$TUNNELBLICK_VERSION /output/tunnelblick
FROM ubuntu as builder
# ------------------------------------------------------
# -- TODO: Define it only once
# ------------------------------------------------------
ARG OPENVPN_VERSION
ARG TUNNELBLICK_VERSION
COPY --from=dudo /output /src
RUN apt-get update &&\
apt-get install -y wget tar unzip build-essential \
libssl-dev iproute2 liblz4-dev liblzo2-dev \
libpam0g-dev libpkcs11-helper1-dev libsystemd-dev \
easy-rsa iptables pkg-config libcap-ng-dev
RUN cp /src/tunnelblick/third_party/sources/openvpn/openvpn-$OPENVPN_VERSION/patches/*.diff /src/openvpn
WORKDIR /src/openvpn
RUN for patch in $(find -type f | grep diff); do\
patch -p1 < $patch;\
done
RUN ./configure --disable-systemd --enable-async-push --enable-iproute2
RUN make && make install
RUN mkdir /output
RUN cp $(which openvpn) /output/
# ------------------------------------------------------
# -- Final container
# ------------------------------------------------------
FROM ubuntu:24.04
LABEL maintainer="allanger <allanger@zohomail.com>"
COPY --from=builder /output /src
# -------------------------------------------------------
# -- Prepare system deps
# -------------------------------------------------------
RUN apt update && apt install openvpn easy-rsa iptables -y && \
mv /src/openvpn $(which openvpn)
# Needed by scripts
ENV OPENVPN /etc/openvpn
# Prevents refused client connection because of an expired CRL
ENV EASYRSA_CRL_DAYS 3650
VOLUME ["/etc/openvpn"]
# Internally uses port 1194, remap if needed using `docker run -p 443:1194/tcp`
EXPOSE 1194
CMD ["ovpn_run"]
COPY --chmod='755' ./bin /usr/local/bin
# -----------------------------------------------------------
# -- Add support for OTP authentication using a PAM module
# -- I have no idea how it works yet
# -----------------------------------------------------------
WORKDIR /etc/openvpn

View File

@ -11,10 +11,12 @@ Note that some client software might be picky about which configuration format i
## Client List
See an overview of the configured clients, including revocation status:
See an overview of the configured clients, including revocation and expiration status:
docker run --rm -it -v $OVPN_DATA:/etc/openvpn kylemanna/openvpn ovpn_listclients
The output is generated using `openssl verify`. Error codes from the verification process different from `X509_V_ERR_CERT_HAS_EXPIRED` or `X509_V_ERR_CERT_REVOKED` will show the status `INVALID`.
## Batch Mode
If you have more than a few clients, you will want to generate and update your client configuration in batch. For this task the script [`ovpn_getclient_all`](/bin/ovpn_getclient_all) was written, which writes out the configuration for each client to a separate directory called `clients/$cn`.
@ -34,9 +36,12 @@ After doing so, you will find the following files in each of the `$cn` directori
## Revoking Client Certificates
Revoke `client1`'s certificate and generate the certificate revocation list (CRL):
Revoke `client1`'s certificate and generate the certificate revocation list (CRL) using [`ovpn_revokeclient`](/bin/ovpn_revokeclient) script :
docker run --rm -it -v $OVPN_DATA:/etc/openvpn kylemanna/openvpn easyrsa revoke client1
docker run --rm -it -v $OVPN_DATA:/etc/openvpn kylemanna/openvpn easyrsa gen-crl
docker run --rm -it -v $OVPN_DATA:/etc/openvpn kylemanna/openvpn ovpn_revokeclient client1
The OpenVPN server will read this change every time a client connects (no need to restart server) and deny clients access using revoked certificates.
You can optionally pass `remove` as second parameter to ovpn_revokeclient to remove the corresponding crt, key and req files :
docker run --rm -it -v $OVPN_DATA:/etc/openvpn kylemanna/openvpn ovpn_revokeclient client1 remove

View File

@ -4,8 +4,8 @@ Random things I do to debug the containers.
## Login Shells
* Create a shell in the running docker container (aka namespace) with [nsenter](https://github.com/jpetazzo/nsenter)
* If you don't have nsenter/docker-enter, you can mount the data container and modify it with
* Create a shell in the running docker container with `docker exec`.
* To modify the data, you can also mount the data container and modify it with
docker run --rm -it -v $OVPN_DATA:/etc/openvpn kylemanna/openvpn bash -l

View File

@ -59,10 +59,19 @@ docker-compose run --rm openvpn easyrsa build-client-full $CLIENTNAME nopass
docker-compose run --rm openvpn ovpn_getclient $CLIENTNAME > $CLIENTNAME.ovpn
```
* Revoke a client certificate
```bash
# Keep the corresponding crt, key and req files.
docker-compose run --rm openvpn ovpn_revokeclient $CLIENTNAME
# Remove the corresponding crt, key and req files.
docker-compose run --rm openvpn ovpn_revokeclient $CLIENTNAME remove
```
## Debugging Tips
* Create an environment variable with the name DEBUG and value of 1 to enable debug output (using "docker -e").
```bash
docker-compose run -e DEBUG=1 openvpn
docker-compose run -e DEBUG=1 -p 1194:1194/udp openvpn
```

View File

@ -2,9 +2,9 @@
## How do I edit `openvpn.conf`?
Use a Docker image with a text editor pre-installed (i.e. Ubuntu) and connect the volume container:
Use a Docker image with an editor and connect the volume container:
docker run -v $OVPN_DATA:/etc/openvpn --rm -it ubuntu vi /etc/openvpn/openvpn.conf
docker run -v $OVPN_DATA:/etc/openvpn --rm -it kylemanna/openvpn vi /etc/openvpn/openvpn.conf
## Why not keep everything in one image?

View File

@ -1,6 +1,6 @@
# Advanced security
## Keep the CA root key save
## Keep the CA root key safe
As mentioned in the [backup section](/docs/backup.md), there are good reasons to not generate the CA and/or leave it on the server. This document describes how you can generate the CA and all your certificates on a secure machine and then copy only the needed files (which never includes the CA root key obviously ;) ) to the server(s) and clients.
Execute the following commands. Note that you might want to change the volume `$PWD` or use a data docker container for this.
@ -13,7 +13,7 @@ The [`ovpn_copy_server_files`](/bin/ovpn_copy_server_files) script puts all the
## Crypto Hardening
If you want to select the cyphers used by OpenVPN the following parameters of the `ovpn_genconfig` might interest you:
If you want to select the ciphers used by OpenVPN the following parameters of the `ovpn_genconfig` might interest you:
-T Encrypt packets with the given cipher algorithm instead of the default one (tls-cipher).
-C A list of allowable TLS ciphers delimited by a colon (cipher).

View File

@ -15,11 +15,17 @@ are harmless for those not using IPv6.
To use and enable automatic start by systemd:
1. Create a Docker volume container named `ovpn-data-NAME` where `NAME` is the
user's choice to describe the use of the container. In the example
configuration given in the [README](/README.md) `NAME=data`.
2. Initialize the data container according to the [docker-openvpn
README](/README.md), but don't start the container. Stop the Docker
container if started.
user's choice to describe the use of the container. In this example
configuration, `NAME=example`.
OVPN_DATA="ovpn-data-example"
docker volume create --name $OVPN_DATA
2. Initialize the data container, but don't start the container :
docker run -v $OVPN_DATA:/etc/openvpn --rm kylemanna/openvpn ovpn_genconfig -u udp://VPN.SERVERNAME.COM
docker run -v $OVPN_DATA:/etc/openvpn --rm -it kylemanna/openvpn ovpn_initpki
3. Download the [docker-openvpn@.service](https://raw.githubusercontent.com/kylemanna/docker-openvpn/master/init/docker-openvpn%40.service)
file to `/etc/systemd/system`:
@ -27,11 +33,11 @@ To use and enable automatic start by systemd:
4. Enable and start the service with:
systemctl enable --now docker-openvpn@NAME.service
systemctl enable --now docker-openvpn@example.service
5. Verify service start-up with:
systemctl status docker-openvpn@NAME.service
journalctl --unit docker-openvpn@NAME.service
systemctl status docker-openvpn@example.service
journalctl --unit docker-openvpn@example.service
For more information, see the [systemd manual pages](https://www.freedesktop.org/software/systemd/man/index.html).

View File

@ -29,3 +29,17 @@ This allows you to use UDP most of the time, but fall back to TCP on the rare oc
Note that you will need to configure client connections manually. At this time it is not possible to generate a client config that will automatically fall back to the TCP connection.
## Forward HTTP/HTTPS connection to another TCP port
You might run into cases where you want your OpenVPN server listening on TCP port 443 to allow connection behind a restricted network, but you already have a webserver on your host running on that port. OpenVPN has a built-in option named `port-share` that allow you to proxy incoming traffic that isn't OpenVPN protocol to another host and port.
First, change the listening port of your existing webserver (for instance from 443 to 4433).
Then initialize the data container by specifying the TCP protocol, port 443 and the port-share option:
docker run -v $OVPN_DATA:/etc/openvpn --rm kylemanna/openvpn ovpn_genconfig \
-u tcp://VPN.SERVERNAME.COM:443 \
-e 'port-share VPN.SERVERNAME.COM 4433'
Then proceed to initialize the pki, create your users and start the container as usual.
This will proxy all non OpenVPN traffic incoming on TCP port 443 to TCP port 4433 on the same host. This is currently only designed to work with HTTP or HTTPS protocol.

3
env/openvpn.env vendored Normal file
View File

@ -0,0 +1,3 @@
export OPENVPN_VERSION=2.6.11
export CONTAINERFILE=./containerfiles/Containerfile
export SCRIPT=build_upstream.sh

3
env/openvpn_xor.env vendored Normal file
View File

@ -0,0 +1,3 @@
export TUNNELBLICK_VERSION=6.0beta03
export CONTAINERFILE=./containerfiles/Containerfile-XOR
export SCRIPT=build_xor.sh

View File

@ -33,8 +33,8 @@
[Unit]
Description=OpenVPN Docker Container
Documentation=https://github.com/kylemanna/docker-openvpn
After=network.target docker.socket
Requires=docker.socket
After=network.target docker.service
Requires=docker.service
[Service]
RestartSec=10
@ -64,7 +64,7 @@ ExecStartPre=-/usr/bin/docker pull $IMG
ExecStartPre=/bin/sh -c 'test -z "$IP6_PREFIX" && exit 0; sysctl net.ipv6.conf.all.forwarding=1'
# Main process
ExecStart=/usr/bin/docker run --rm --privileged -v ${DATA_VOL}:/etc/openvpn --name ${NAME} -p ${PORT} ${IMG} ovpn_run $ARGS
ExecStart=/usr/bin/docker run --rm --cap-add=NET_ADMIN -v ${DATA_VOL}:/etc/openvpn --name ${NAME} -p ${PORT} ${IMG} ovpn_run $ARGS
# IPv6: Add static route for IPv6 after it starts up
ExecStartPost=/bin/sh -c 'test -z "${IP6_PREFIX}" && exit 0; sleep 1; ip route replace ${IP6_PREFIX} via $(docker inspect -f "{{ .NetworkSettings.GlobalIPv6Address }}" $NAME ) dev docker0'

View File

@ -4,5 +4,5 @@ start on filesystem and started docker
stop on runlevel [!2345]
respawn
script
exec docker run -v ovpn-data:/etc/openvpn --rm -p 1194:1194/udp --cap-add=NET_ADMIN kylemanna/openvpn
exec docker run -v ovpn-data-example:/etc/openvpn --rm -p 1194:1194/udp --cap-add=NET_ADMIN kylemanna/openvpn
end script

View File

@ -1,7 +0,0 @@
# Uses google authenticator library as PAM module using a single folder for all users tokens
# User root is required to stick with an hardcoded user when trying to determine user id and allow unexisting system users
# See https://github.com/google/google-authenticator/tree/master/libpam#secretpathtosecretfile--usersome-user
auth required pam_google_authenticator.so secret=/etc/openvpn/otp/${USER}.google_authenticator user=root
# Accept any user since we're dealing with virtual users there's no need to have a system account (pam_unix.so)
account sufficient pam_permit.so

4
scripts/build_upstream.sh Executable file
View File

@ -0,0 +1,4 @@
#!/usr/bin/env sh
export CUSTOM_TAG="v$OPENVPN_VERSION"
export BUILD_ARGS="--build-arg OPENVPN_VERSION=$OPENVPN_VERSION"
build-container

6
scripts/build_xor.sh Executable file
View File

@ -0,0 +1,6 @@
#!/usr/bin/env sh
git clone https://github.com/Tunnelblick/Tunnelblick.git /tmp/tunnelblick
export OPENVPN_VERSION=$(ls /tmp/tunnelblick/third_party/sources/openvpn | sed 's/openvpn-//g' | sort -k1,1nr -k2,2n -k3,3n | head -n 1)
export CUSTOM_TAG="v$OPENVPN_VERSION-XOR-$TUNNELBLICK_VERSION"
export BUILD_ARGS="--build-arg OPENVPN_VERSION=$OPENVPN_VERSION --build-arg TUNNELBLICK_VERSION=$TUNNELBLICK_VERSION"
build-container

View File

@ -9,9 +9,11 @@ imageTests+=(
[openvpn]='
paranoid
conf_options
client
basic
dual-proto
otp
iptables
revocation
'
)

View File

@ -0,0 +1,84 @@
#!/bin/bash
SERV_IP=$(ip -4 -o addr show scope global | awk '{print $4}' | sed -e 's:/.*::' | head -n1)
SERVER_CONF="/etc/openvpn/openvpn.conf"
TEST1_OVPN="/etc/openvpn/test1.ovpn"
# Function to fail
abort() { cat <<< "$@" 1>&2; exit 1; }
# Check a config (haystack) for a given line (needle) exit with error if not
# found.
test_config() {
local needle="${2}"
local file="${1}"
busybox grep -q "${needle}" "${file}"
if [ $? -ne 0 ]; then
abort "==> Config match not found: ${needle}"
fi
}
# Check a config (haystack) for absence of given line (needle) exit with error
# if found.
test_not_config() {
local needle="${2}"
local file="${1}"
busybox grep -vq "${needle}" "${file}"
if [ $? -ne 0 ]; then
abort "==> Config match found: ${needle}"
fi
}
#
# Generate openvpn.config file
#
ovpn_genconfig \
-u udp://$SERV_IP \
-m 1337 \
EASYRSA_BATCH=1 EASYRSA_REQ_CN="Travis-CI Test CA" ovpn_initpki nopass
easyrsa build-client-full test1 nopass 2>/dev/null
ovpn_getclient test1 > "${TEST1_OVPN}"
#
# Simple test cases
#
# 1. client MTU
test_config "${TEST1_OVPN}" "^tun-mtu\s\+1337"
#
# Test udp client with tcp fallback
#
ovpn_genconfig -u udp://$SERV_IP -E "remote $SERV_IP 443 tcp" -E "remote vpn.example.com 443 tcp"
# nopass is insecure
EASYRSA_BATCH=1 EASYRSA_REQ_CN="Travis-CI Test CA" ovpn_initpki nopass
easyrsa build-client-full client-fallback nopass
ovpn_getclient client-fallback > "${TEST1_OVPN}"
test_config "${TEST1_OVPN}" "^remote\s\+$SERV_IP\s\+443\s\+tcp"
test_config "${TEST1_OVPN}" "^remote\s\+vpn.example.com\s\+443\s\+tcp"
#
# Test non-defroute config
#
ovpn_genconfig -d -u udp://$SERV_IP -r "172.33.33.0/24" -r "172.34.34.0/24"
# nopass is insecure
EASYRSA_BATCH=1 EASYRSA_REQ_CN="Travis-CI Test CA" ovpn_initpki nopass
easyrsa build-client-full non-defroute nopass
ovpn_getclient non-defroute > "${TEST1_OVPN}"
# The '!' inverts the match to test that the string isn't present
test_not_config "${TEST1_OVPN}" "^redirect-gateway\s\+def1"

1
test/tests/client/run.sh Symbolic link
View File

@ -0,0 +1 @@
../run-bash-in-container.sh

View File

@ -1,8 +1,37 @@
#!/bin/bash
SERV_IP=$(ip -4 -o addr show scope global | awk '{print $4}' | sed -e 's:/.*::' | head -n1)
SERVER_CONF="/etc/openvpn/openvpn.conf"
TEST1_OVPN="/etc/openvpn/test1.ovpn"
# Function to fail
abort() { cat <<< "$@" 1>&2; exit 1; }
# Check a config (haystack) for a given line (needle) exit with error if not found.
test_config() {
local needle="${2}"
local file="${1}"
busybox grep -q "${needle}" "${file}"
if [ $? -ne 0 ]; then
abort "==> Config match not found: ${needle}"
fi
}
# Check a config (haystack) for absence of given line (needle) exit with error
# if found.
test_not_config() {
local needle="${2}"
local file="${1}"
busybox grep -vq "${needle}" "${file}"
if [ $? -ne 0 ]; then
abort "==> Config match found: ${needle}"
fi
}
#
# Generate openvpn.config file
@ -12,183 +41,76 @@ management localhost 7505
max-clients 10
EOF
SERV_IP=$(ip -4 -o addr show scope global | awk '{print $4}' | sed -e 's:/.*::' | head -n1)
ovpn_genconfig -u udp://$SERV_IP -f 1400 -e "$MULTILINE_EXTRA_SERVER_CONF" -e 'duplicate-cn' -e 'topology subnet' -p 'route 172.22.22.0 255.255.255.0'
ovpn_genconfig \
-u udp://$SERV_IP \
-f 1400 \
-k '60 300' \
-e "$MULTILINE_EXTRA_SERVER_CONF" \
-e 'duplicate-cn' \
-e 'topology subnet' \
-p 'route 172.22.22.0 255.255.255.0' \
# Run ovpn_genconfig a second time with no arguments to test its repeatability.
ovpn_genconfig
#
# grep for config lines from openvpn.conf
# add more tests for more configs as required
# Simple test cases
#
# 1. verb config
CONFIG_REQUIRED_VERB="verb 3"
CONFIG_MATCH_VERB=$(busybox grep verb /etc/openvpn/openvpn.conf)
test_config "${SERVER_CONF}" "^verb\s\+3"
# 2. fragment config
CONFIG_REQUIRED_FRAGMENT="fragment 1400"
CONFIG_MATCH_FRAGMENT=$(busybox grep fragment /etc/openvpn/openvpn.conf)
test_config "${SERVER_CONF}" "^fragment\s\+1400"
## Tests for extra configs
# 3. management config
CONFIG_REQUIRED_MANAGEMENT="^management localhost 7505"
CONFIG_MATCH_MANAGEMENT=$(busybox grep management /etc/openvpn/openvpn.conf)
test_config "${SERVER_CONF}" "^management\s\+localhost\s\+7505"
# 4. max-clients config
CONFIG_REQUIRED_MAX_CLIENTS="^max-clients 10"
CONFIG_MATCH_MAX_CLIENTS=$(busybox grep max-clients /etc/openvpn/openvpn.conf)
test_config "${SERVER_CONF}" "^max-clients\s\+10"
# 5. duplicate-cn config
CONFIG_REQUIRED_DUPCN="^duplicate-cn"
CONFIG_MATCH_DUPCN=$(busybox grep duplicate-cn /etc/openvpn/openvpn.conf)
test_config "${SERVER_CONF}" "^duplicate-cn"
# 6. topology config
CONFIG_REQUIRED_TOPOLOGY="^topology subnet"
CONFIG_MATCH_TOPOLOGY=$(busybox grep 'topology subnet' /etc/openvpn/openvpn.conf)
test_config "${SERVER_CONF}" "^topology\s\+subnet"
## Tests for push config
# 7. push route
CONFIG_REQUIRED_PUSH_ROUTE="^push route 172.22.22.0 255.255.255.0"
CONFIG_MATCH_PUSH_ROUTE=$(busybox grep 'push route 172.22.22.0 255.255.255.0' /etc/openvpn/openvpn.conf)
test_config "${SERVER_CONF}" '^push\s\+"route\s\+172.22.22.0\s\+255.255.255.0"'
## Test for default
# 8. Should see default route if none provided
CONFIG_REQUIRED_DEFAULT_ROUTE="^route 192.168.254.0 255.255.255.0"
CONFIG_MATCH_DEFAULT_ROUTE=$(busybox grep 'route 192.168.254.0 255.255.255.0' /etc/openvpn/openvpn.conf)
test_config "${SERVER_CONF}" "^route\s\+192.168.254.0\s\+255.255.255.0"
# 9. Should see a push of 'block-outside-dns' by default
CONFIG_REQUIRED_DEFAULT_ROUTE="^push block-outside-dns"
CONFIG_MATCH_DEFAULT_ROUTE=$(busybox grep 'push block-outside-dns' /etc/openvpn/openvpn.conf)
test_config "${SERVER_CONF}" '^push\s\+"block-outside-dns"'
# 10. Should see a push of 'dhcp-option DNS' by default
CONFIG_REQUIRED_DEFAULT_DNS_1="^push dhcp-option DNS 8.8.8.8"
CONFIG_MATCH_DEFAULT_DNS_1=$(busybox grep 'push dhcp-option DNS 8.8.8.8' /etc/openvpn/openvpn.conf)
CONFIG_REQUIRED_DEFAULT_DNS_2="^push dhcp-option DNS 8.8.4.4"
CONFIG_MATCH_DEFAULT_DNS_2=$(busybox grep 'push dhcp-option DNS 8.8.4.4' /etc/openvpn/openvpn.conf)
test_config "${SERVER_CONF}" '^push\s\+"dhcp-option\s\+DNS\s\+8.8.8.8"'
test_config "${SERVER_CONF}" '^push\s\+"dhcp-option\s\+DNS\s\+8.8.4.4"'
## Test for keepalive
# 11. keepalive config
test_config "${SERVER_CONF}" '^keepalive\s\+60\s\+300'
#
# Tests
# More elaborate route tests
#
if [[ $CONFIG_MATCH_VERB =~ $CONFIG_REQUIRED_VERB ]]
then
echo "==> Config match found: $CONFIG_REQUIRED_VERB == $CONFIG_MATCH_VERB"
else
abort "==> Config match not found: $CONFIG_REQUIRED_VERB != $CONFIG_MATCH_VERB"
fi
if [[ $CONFIG_MATCH_FRAGMENT =~ $CONFIG_REQUIRED_FRAGMENT ]]
then
echo "==> Config match found: $CONFIG_REQUIRED_FRAGMENT == $CONFIG_MATCH_FRAGMENT"
else
abort "==> Config match not found: $CONFIG_REQUIRED_FRAGMENT != $CONFIG_MATCH_FRAGMENT"
fi
if [[ $CONFIG_MATCH_MANAGEMENT =~ $CONFIG_REQUIRED_MANAGEMENT ]]
then
echo "==> Config match found: $CONFIG_REQUIRED_MANAGEMENT == $CONFIG_MATCH_MANAGEMENT"
else
abort "==> Config match not found: $CONFIG_REQUIRED_MANAGEMENT != $CONFIG_MATCH_MANAGEMENT"
fi
if [[ $CONFIG_MATCH_MAX_CLIENTS =~ $CONFIG_REQUIRED_MAX_CLIENTS ]]
then
echo "==> Config match found: $CONFIG_REQUIRED_MAX_CLIENTS == $CONFIG_MATCH_MAX_CLIENTS"
else
abort "==> Config match not found: $CONFIG_REQUIRED_MAX_CLIENTS != $CONFIG_MATCH_MAX_CLIENTS"
fi
if [[ $CONFIG_MATCH_DUPCN =~ $CONFIG_REQUIRED_DUPCN ]]
then
echo "==> Config match found: $CONFIG_REQUIRED_DUPCN == $CONFIG_MATCH_DUPCN"
else
abort "==> Config match not found: $CONFIG_REQUIRED_DUPCN != $CONFIG_MATCH_DUPCN"
fi
if [[ $CONFIG_MATCH_TOPOLOGY =~ $CONFIG_REQUIRED_TOPOLOGY ]]
then
echo "==> Config match found: $CONFIG_REQUIRED_TOPOLOGY == $CONFIG_MATCH_TOPOLOGY"
else
abort "==> Config match not found: $CONFIG_REQUIRED_TOPOLOGY != $CONFIG_MATCH_TOPOLOGY"
fi
if [[ $CONFIG_MATCH_PUSH_ROUTE =~ $CONFIG_REQUIRED_PUSH_ROUTE ]]
then
echo "==> Config match found: $CONFIG_REQUIRED_PUSH_ROUTE == $CONFIG_MATCH_PUSH_ROUTE"
else
abort "==> Config match not found: $CONFIG_REQUIRED_PUSH_ROUTE != $CONFIG_MATCH_PUSH_ROUTE"
fi
if [[ $CONFIG_MATCH_DEFAULT_ROUTE =~ $CONFIG_REQUIRED_DEFAULT_ROUTE ]]
then
echo "==> Config match found: $CONFIG_REQUIRED_DEFAULT_ROUTE == $CONFIG_MATCH_DEFAULT_ROUTE"
else
abort "==> Config match not found: $CONFIG_REQUIRED_DEFAULT_ROUTE != $CONFIG_MATCH_DEFAULT_ROUTE"
fi
if [[ $CONFIG_MATCH_DEFAULT_DNS_1 =~ $CONFIG_REQUIRED_DEFAULT_DNS_1 ]]
then
echo "==> Config match found: $CONFIG_REQUIRED_DEFAULT_DNS_1 == $CONFIG_MATCH_DEFAULT_DNS_1"
else
abort "==> Config match not found: $CONFIG_REQUIRED_DEFAULT_DNS_1 != $CONFIG_MATCH_DEFAULT_DNS_1"
fi
if [[ $CONFIG_MATCH_DEFAULT_DNS_2 =~ $CONFIG_REQUIRED_DEFAULT_DNS_2 ]]
then
echo "==> Config match found: $CONFIG_REQUIRED_DEFAULT_DNS_2 == $CONFIG_MATCH_DEFAULT_DNS_2"
else
abort "==> Config match not found: $CONFIG_REQUIRED_DEFAULT_DNS_2 != $CONFIG_MATCH_DEFAULT_DNS_2"
fi
SERV_IP=$(ip -4 -o addr show scope global | awk '{print $4}' | sed -e 's:/.*::' | head -n1)
ovpn_genconfig -u udp://$SERV_IP -r "172.33.33.0/24" -r "172.34.34.0/24"
CONFIG_REQUIRED_ROUTE_1="^route 172.33.33.0 255.255.255.0"
CONFIG_MATCH_ROUTE_1=$(busybox grep 'route 172.33.33.0 255.255.255.0' /etc/openvpn/openvpn.conf)
test_config "${SERVER_CONF}" "^route\s\+172.33.33.0\s\+255.255.255.0"
test_config "${SERVER_CONF}" "^route\s\+172.34.34.0\s\+255.255.255.0"
CONFIG_REQUIRED_ROUTE_2="^route 172.34.34.0 255.255.255.0"
CONFIG_MATCH_ROUTE_2=$(busybox grep 'route 172.34.34.0 255.255.255.0' /etc/openvpn/openvpn.conf)
if [[ $CONFIG_MATCH_ROUTE_1 =~ $CONFIG_REQUIRED_ROUTE_1 ]]
then
echo "==> Config match found: $CONFIG_REQUIRED_ROUTE_1 == $CONFIG_MATCH_ROUTE_1"
else
abort "==> Config match not found: $CONFIG_REQUIRED_ROUTE_1 != $CONFIG_MATCH_ROUTE_1"
fi
#
# Block outside DNS test
#
if [[ $CONFIG_MATCH_ROUTE_2 =~ $CONFIG_REQUIRED_ROUTE_2 ]]
then
echo "==> Config match found: $CONFIG_REQUIRED_ROUTE_2 == $CONFIG_MATCH_ROUTE_2"
else
abort "==> Config match not found: $CONFIG_REQUIRED_ROUTE_2 != $CONFIG_MATCH_ROUTE_2"
fi
ovpn_genconfig -u udp://$SERV_IP -b
# Test generated client config
# gen udp client with tcp fallback
ovpn_genconfig -u udp://$SERV_IP -E "remote $SERV_IP 443 tcp" -E "remote vpn.example.com 443 tcp"
# nopass is insecure
EASYRSA_BATCH=1 EASYRSA_REQ_CN="Travis-CI Test CA" ovpn_initpki nopass
easyrsa build-client-full client-fallback nopass
ovpn_getclient client-fallback | tee /etc/openvpn/config-fallback.ovpn
CONFIG_REQUIRED_TCP_REMOTE="^remote $SERV_IP 443 tcp"
CONFIG_MATCH_TCP_REMOTE=$(busybox grep "remote $SERV_IP 443 tcp" /etc/openvpn/config-fallback.ovpn)
CONFIG_REQUIRED_TCP_REMOTE_2="^remote vpn.example.com 443 tcp"
CONFIG_MATCH_TCP_REMOTE_2=$(busybox grep "remote vpn.example.com 443 tcp" /etc/openvpn/config-fallback.ovpn)
if [[ $CONFIG_MATCH_TCP_REMOTE =~ $CONFIG_REQUIRED_TCP_REMOTE ]]
then
echo "==> Config match found: $CONFIG_REQUIRED_TCP_REMOTE == $CONFIG_MATCH_TCP_REMOTE"
else
abort "==> Config match not found: $CONFIG_REQUIRED_TCP_REMOTE != $CONFIG_MATCH_TCP_REMOTE"
fi
if [[ $CONFIG_MATCH_TCP_REMOTE_2 =~ $CONFIG_REQUIRED_TCP_REMOTE_2 ]]
then
echo "==> Config match found: $CONFIG_REQUIRED_TCP_REMOTE_2 == $CONFIG_MATCH_TCP_REMOTE_2"
else
abort "==> Config match not found: $CONFIG_REQUIRED_TCP_REMOTE_2 != $CONFIG_MATCH_TCP_REMOTE_2"
fi
test_not_config "${SERVER_CONF}" '^push "block-outside-dns"'
cat ${SERVER_CONF} >&1

101
test/tests/revocation/run.sh Executable file
View File

@ -0,0 +1,101 @@
#!/bin/bash
set -e
[ -n "${DEBUG+x}" ] && set -x
OVPN_DATA="basic-data"
CLIENT1="travis-client1"
CLIENT2="travis-client2"
IMG="kylemanna/openvpn"
NAME="ovpn-test"
CLIENT_DIR="$(readlink -f "$(dirname "$BASH_SOURCE")/../../client")"
SERV_IP="$(ip -4 -o addr show scope global | awk '{print $4}' | sed -e 's:/.*::' | head -n1)"
#
# Initialize openvpn configuration and pki.
#
docker volume create --name $OVPN_DATA
docker run --rm -v $OVPN_DATA:/etc/openvpn $IMG ovpn_genconfig -u udp://$SERV_IP
docker run --rm -v $OVPN_DATA:/etc/openvpn -it -e "EASYRSA_BATCH=1" -e "EASYRSA_REQ_CN=Travis-CI Test CA" $IMG ovpn_initpki nopass
#
# Fire up the server.
#
sudo iptables -N DOCKER || echo 'Firewall already configured'
sudo iptables -I FORWARD 1 -j DOCKER
docker run -d -v $OVPN_DATA:/etc/openvpn --cap-add=NET_ADMIN --privileged -p 1194:1194/udp --name $NAME $IMG
#
# Test that easy_rsa generate CRLs with 'next publish' set to 3650 days.
#
crl_next_update="$(docker exec $NAME openssl crl -nextupdate -noout -in /etc/openvpn/crl.pem | cut -d'=' -f2 | tr -d 'GMT')"
crl_next_update="$(date -u -d "$crl_next_update" "+%s")"
now="$(docker exec $NAME date "+%s")"
crl_remain="$(( $crl_next_update - $now ))"
crl_remain="$(( $crl_remain / 86400 ))"
if (( $crl_remain < 3649 )); then
echo "easy_rsa CRL next publish set to less than 3650 days." >&2
exit 2
fi
#
# Generate a first client certificate and configuration using $CLIENT1 as CN then revoke it.
#
docker exec -it $NAME easyrsa build-client-full $CLIENT1 nopass
docker exec -it $NAME ovpn_getclient $CLIENT1 > $CLIENT_DIR/config.ovpn
docker exec -it $NAME bash -c "echo 'yes' | ovpn_revokeclient $CLIENT1 remove"
#
# Test that openvpn client can't connect using $CLIENT1 config.
#
if docker run --rm -v $CLIENT_DIR:/client --cap-add=NET_ADMIN --privileged --net=host $IMG /client/wait-for-connect.sh; then
echo "Client was able to connect after revocation test #1." >&2
exit 2
fi
#
# Generate and revoke a second client certificate using $CLIENT2 as CN, then test for failed client connection.
#
docker exec -it $NAME easyrsa build-client-full $CLIENT2 nopass
docker exec -it $NAME ovpn_getclient $CLIENT2 > $CLIENT_DIR/config.ovpn
docker exec -it $NAME bash -c "echo 'yes' | ovpn_revokeclient $CLIENT2 remove"
if docker run --rm -v $CLIENT_DIR:/client --cap-add=NET_ADMIN --privileged --net=host $IMG /client/wait-for-connect.sh; then
echo "Client was able to connect after revocation test #2." >&2
exit 2
fi
#
# Restart the server
#
docker stop $NAME && docker start $NAME
#
# Test for failed connection using $CLIENT2 config again.
#
if docker run --rm -v $CLIENT_DIR:/client --cap-add=NET_ADMIN --privileged --net=host $IMG /client/wait-for-connect.sh; then
echo "Client was able to connect after revocation test #3." >&2
exit 2
fi
#
# Stop the server and clean up
#
docker kill $NAME && docker rm $NAME
docker volume rm $OVPN_DATA
sudo iptables -D FORWARD 1
#
# Celebrate
#
cat <<EOF
___________
< it worked >
-----------
\ ^__^
\ (oo)\_______
(__)\ )\/\\
||----w |
|| ||
EOF