Browse Source

Updated the OpenVPN role so certificate expiration is handled

correctly. The number of days that a certificate will be considered
valid is now a user-controlled variable and is set to five years by
default. (Fixes Issue #87)
Joshua Lund 11 years ago
parent
commit
1b81d7a7e6

+ 2
- 2
roles/vpn/tasks/openvpn.yml View File

@@ -32,7 +32,7 @@
32 32
         mode=600
33 33
 
34 34
 - name: Generate CA certificate
35
-  command: openssl req -nodes -batch -new -x509 -key {{ openvpn_ca }}.key -out {{ openvpn_ca }}.crt -subj "{{ openssl_request_subject }}/CN=ca-certificate"
35
+  command: openssl req -nodes -batch -new -x509 -key {{ openvpn_ca }}.key -out {{ openvpn_ca }}.crt -days {{ openvpn_days_valid }} -subj "{{ openssl_request_subject }}/CN=ca-certificate"
36 36
            creates={{ openvpn_ca }}.crt
37 37
 
38 38
 - name: Generate the OpenSSL configuration that will be used for the Server certificate's req and ca commands
@@ -70,7 +70,7 @@
70 70
   with_items: openvpn_clients
71 71
 
72 72
 - name: Generate certificates for the clients
73
-  command: openssl x509 -CA {{ openvpn_ca }}.crt -CAkey {{ openvpn_ca }}.key -CAcreateserial -req -in {{ item }}.csr -out {{ item }}.crt
73
+  command: openssl x509 -CA {{ openvpn_ca }}.crt -CAkey {{ openvpn_ca }}.key -CAcreateserial -req -days {{ openvpn_days_valid }} -in {{ item }}.csr -out {{ item }}.crt
74 74
            chdir={{ openvpn_path }}
75 75
            creates={{ item }}.crt
76 76
   with_items: openvpn_clients

+ 1
- 1
roles/vpn/templates/openssl-server-certificate.cnf.j2 View File

@@ -17,7 +17,7 @@ RANDFILE = $dir/.rand
17 17
 
18 18
 x509_extensions = server
19 19
 
20
-default_days = 3650
20
+default_days = {{ openvpn_days_valid }}
21 21
 default_crl_days= 30
22 22
 default_md = sha256
23 23
 preserve = no

+ 2
- 1
vars/defaults.yml View File

@@ -61,7 +61,8 @@ znc_version: 1.0
61 61
 tarsnap_version: 1.0.35
62 62
 
63 63
 # # vpn
64
-openvpn_key_country:  "US"
64
+openvpn_days_valid: "1825"
65
+openvpn_key_country: "US"
65 66
 openvpn_key_province: "California"
66 67
 openvpn_key_city: "Beverly Hills"
67 68
 openvpn_key_org: "ACME CORPORATION"

+ 1
- 0
vars/user.yml View File

@@ -61,6 +61,7 @@
61 61
 # tarsnap_version: 1.0.35
62 62
 
63 63
 # # vpn
64
+# openvpn_days_valid: "1825"
64 65
 # openvpn_key_country:  "US"
65 66
 # openvpn_key_province: "California"
66 67
 # openvpn_key_city: "Beverly Hills"

Loading…
Cancel
Save