Skip to content
This repository has been archived by the owner on Apr 11, 2024. It is now read-only.

Commit

Permalink
VPN server certificate renewal fixes #139
Browse files Browse the repository at this point in the history
  • Loading branch information
markushuber committed Aug 3, 2019
1 parent 67c638a commit cef725b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
3 changes: 3 additions & 0 deletions roles/vpn/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,9 @@
- restart openvpn
- restart openvpn-su

- name: deploy Server Certificate renewal cronjob
template: src=server-cert-renewal.sh dest=/etc/cron.weekly/openvpn-server-cert owner=root group=root mode=0755

- name: deleting unused files
file: path={{item}} state=absent
with_items:
Expand Down
12 changes: 12 additions & 0 deletions roles/vpn/templates/server-cert-renewal.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

days=60

#Test if certificate expires in the next 60 days
/usr/bin/openssl x509 -checkend $(($days * 24 * 3600)) -in /etc/openvpn/ca/serverCert.pem

if [ $? -eq 1 ]
then
openssl ca -in /etc/openvpn/ca/serverReq.pem -days 730 -batch -out /etc/openvpn/ca/serverCert.pem -notext -cert /etc/openvpn/ca/caCert.pem -keyfile /etc/openvpn/ca/caKey.pem
service openvpn-su restart
fi

0 comments on commit cef725b

Please sign in to comment.