Skip to content

Commit 090a60d

Browse files
jackivanovdguido
authored andcommitted
PKI to tmpfs (#1496)
* PKI to tmpfs * Fixes - diskutil to full path - unmount and eject fixes * Umount fix * run diskutil info only on Darwin kernels * fix shell tasks
1 parent f986811 commit 090a60d

File tree

19 files changed

+128
-34
lines changed

19 files changed

+128
-34
lines changed

config.cfg

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ users:
1111

1212
### Advanced users only below this line ###
1313

14+
# Store the PKI in a ram disk. Enabled only if store_pki (retain the PKI) is set to false
15+
# Supports on MacOS and Linux only (including Windows Subsystem for Linux)
16+
pki_in_tmpfs: true
17+
1418
# If True re-init all existing certificates. Boolean
1519
keys_clean_all: False
1620

docs/cloud-do.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ ansible-playbook main.yml -e "provider=digitalocean
8787
dns_adblocking=false
8888
ssh_tunneling=false
8989
windows=false
90-
store_cakey=true
90+
store_pki=true
9191
region=nyc3
9292
do_token=token"
9393
```

docs/deploy-from-ansible.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ ansible-playbook main.yml -e "provider=digitalocean
1818
dns_adblocking=true
1919
ssh_tunneling=true
2020
windows=false
21-
store_cakey=true
21+
store_pki=true
2222
region=ams3
2323
do_token=token"
2424
```

docs/deploy-from-script-or-cloud-init-to-localhost.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ The command will prepare the environment and install AlgoVPN with the default pa
1919
`ONDEMAND_WIFI` - "Connect On Demand" when connected to Wi-Fi. Default: false.
2020
`ONDEMAND_WIFI_EXCLUDE` - List the names of any trusted Wi-Fi networks where macOS/iOS IPsec clients should not use "Connect On Demand". Comma-separated list.
2121
`WINDOWS` - To support Windows 10 or Linux Desktop clients. Default: false.
22-
`STORE_CAKEY` - To retain the CA key. (required to add users in the future, but less secure). Default: false.
22+
`STORE_PKI` - To retain the PKI. (required to add users in the future, but less secure). Default: false.
2323
`DNS_ADBLOCKING` - To install an ad blocking DNS resolver. Default: false.
2424
`SSH_TUNNELING` - Enable SSH tunneling for each user. Default: false.
2525
`ENDPOINT` - The public IP address or domain name of your server: (IMPORTANT! This is used to verify the certificate). It will be gathered automatically for DigitalOcean, AWS, GCE, Azure or Vultr if the `METHOD` is cloud. Otherwise you need to define this variable according to your public IP address.

input.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
dns_adblocking: false
1111
ssh_tunneling: false
1212
windows: false
13-
store_cakey: false
13+
store_pki: false
1414
providers_map:
1515
- { name: DigitalOcean, alias: digitalocean }
1616
- { name: Amazon Lightsail, alias: lightsail }
@@ -87,13 +87,13 @@
8787
register: _windows
8888
when: windows is undefined
8989

90-
- name: Retain the CA key prompt
90+
- name: Retain the PKI prompt
9191
pause:
9292
prompt: |
93-
Do you want to retain the CA key? (required to add users in the future, but less secure)
93+
Do you want to retain the keys (PKI)? (required to add users in the future, but less secure)
9494
[y/N]
95-
register: _store_cakey
96-
when: store_cakey is undefined
95+
register: _store_pki
96+
when: store_pki is undefined
9797
when: ipsec_enabled
9898

9999
- name: DNS adblocking prompt
@@ -145,9 +145,9 @@
145145
{% if windows is defined %}{{ windows | bool }}
146146
{%- elif _windows.user_input is defined %}{{ booleans_map[_windows.user_input] | default(defaults['windows']) }}
147147
{%- else %}false{% endif %}
148-
algo_store_cakey: >-
149-
{% if ipsec_enabled %}{%- if store_cakey is defined %}{{ store_cakey | bool }}
150-
{%- elif _store_cakey.user_input is defined %}{{ booleans_map[_store_cakey.user_input] | default(defaults['store_cakey']) }}
148+
algo_store_pki: >-
149+
{% if ipsec_enabled %}{%- if store_pki is defined %}{{ store_pki | bool }}
150+
{%- elif _store_pki.user_input is defined %}{{ booleans_map[_store_pki.user_input] | default(defaults['store_pki']) }}
151151
{%- else %}false{% endif %}{% endif %}
152152
rescue:
153153
- include_tasks: playbooks/rescue.yml

install.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ ONDEMAND_CELLULAR="${2:-${ONDEMAND_CELLULAR:-false}}"
77
ONDEMAND_WIFI="${3:-${ONDEMAND_WIFI:-false}}"
88
ONDEMAND_WIFI_EXCLUDE="${4:-${ONDEMAND_WIFI_EXCLUDE:-_null}}"
99
WINDOWS="${5:-${WINDOWS:-false}}"
10-
STORE_CAKEY="${6:-${STORE_CAKEY:-false}}"
10+
STORE_PKI="${6:-${STORE_PKI:-false}}"
1111
DNS_ADBLOCKING="${7:-${DNS_ADBLOCKING:-false}}"
1212
SSH_TUNNELING="${8:-${SSH_TUNNELING:-false}}"
1313
ENDPOINT="${9:-${ENDPOINT:-localhost}}"
@@ -92,7 +92,7 @@ deployAlgo() {
9292
-e "ondemand_wifi=${ONDEMAND_WIFI}" \
9393
-e "ondemand_wifi_exclude=${ONDEMAND_WIFI_EXCLUDE}" \
9494
-e "windows=${WINDOWS}" \
95-
-e "store_cakey=${STORE_CAKEY}" \
95+
-e "store_pki=${STORE_PKI}" \
9696
-e "dns_adblocking=${DNS_ADBLOCKING}" \
9797
-e "ssh_tunneling=${SSH_TUNNELING}" \
9898
-e "endpoint=$ENDPOINT" \

playbooks/cloud-post.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
algo_dns_adblocking: "{{ algo_dns_adblocking }}"
1919
algo_ssh_tunneling: "{{ algo_ssh_tunneling }}"
2020
algo_windows: "{{ algo_windows }}"
21-
algo_store_cakey: "{{ algo_store_cakey }}"
21+
algo_store_pki: "{{ algo_store_pki }}"
2222
IP_subject_alt_name: "{{ IP_subject_alt_name }}"
2323

2424
- name: Additional variables for the server
@@ -37,6 +37,14 @@
3737
state: present
3838
when: cloud_instance_ip != "localhost"
3939

40+
- name: Mount tmpfs
41+
import_tasks: tmpfs/main.yml
42+
when:
43+
- pki_in_tmpfs
44+
- not algo_store_pki
45+
- ansible_system == "Darwin" or
46+
ansible_system == "Linux"
47+
4048
- debug:
4149
var: IP_subject_alt_name
4250

playbooks/tmpfs/linux.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
- name: Linux | set OS specific facts
3+
set_fact:
4+
tmpfs_volume_name: "AlgoVPN-{{ IP_subject_alt_name }}"
5+
tmpfs_volume_path: /dev/shm

playbooks/tmpfs/macos.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
- name: MacOS | set OS specific facts
3+
set_fact:
4+
tmpfs_volume_name: "AlgoVPN-{{ IP_subject_alt_name }}"
5+
tmpfs_volume_path: /Volumes
6+
7+
- name: MacOS | mount a ram disk
8+
shell: >
9+
/usr/sbin/diskutil info "/{{ tmpfs_volume_path }}/{{ tmpfs_volume_name }}/" ||
10+
/usr/sbin/diskutil erasevolume HFS+ "{{ tmpfs_volume_name }}" $(hdiutil attach -nomount ram://64000)
11+
args:
12+
creates: "/{{ tmpfs_volume_path }}/{{ tmpfs_volume_name }}"

playbooks/tmpfs/main.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
- name: Include tasks for MacOS
3+
import_tasks: macos.yml
4+
when: ansible_system == "Darwin"
5+
6+
- name: Include tasks for Linux
7+
import_tasks: linux.yml
8+
when: ansible_system == "Linux"
9+
10+
- name: Set config paths as facts
11+
set_fact:
12+
wireguard_pki_path: "/{{ tmpfs_volume_path }}/{{ tmpfs_volume_name }}/WireGuard/"
13+
ipsec_pki_path: "/{{ tmpfs_volume_path }}/{{ tmpfs_volume_name }}/IPsec/"
14+
15+
- name: Update config paths
16+
add_host:
17+
name: "{{ 'localhost' if cloud_instance_ip == 'localhost' else cloud_instance_ip }}"
18+
wireguard_pki_path: "{{ wireguard_pki_path }}"
19+
ipsec_pki_path: "{{ ipsec_pki_path }}"

0 commit comments

Comments
 (0)