-
Notifications
You must be signed in to change notification settings - Fork 8
/
getssl
executable file
·41 lines (36 loc) · 1.42 KB
/
getssl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env python3
import sys
from nginx import Nginx
from nginx_proxy import SSL
import os
def print_usage():
print("Usage: Obtain Let'sEncrypt ssl certificate for a domain or multiple domains ")
print()
print(" getssl [--options] <hostname1> [ hostname2 hostname3 ...]")
print()
print("Available options")
print(" --skip-dns-check Do not perform check if dns points to this machine")
print(" --new Override if certificate already exists")
print(" --force Do no perform any check and call acme directly")
exit(1)
if __name__ == "__main__":
if len(sys.argv) < 2:
print_usage()
arg_set = set(sys.argv[1:])
kwargs = {}
if 'h' in arg_set or "-h" in arg_set or "--help" in arg_set or "-help" in arg_set or "help" in arg_set:
print_usage()
else:
if "--force" in arg_set:
kwargs["no_self_check"] = True
kwargs["ignore_existing"] = True
if "--new" in arg_set:
kwargs["ignore_existing"] = True
if "--skip-dns-check" in arg_set:
kwargs["no_self_check"] = True
config = "/etc/nginx/conf.d/gen-ssl-direct.conf"
nginx = Nginx.Nginx(config)
ssl = SSL.SSL("/etc/ssl", nginx=nginx)
ssl.register_certificate([x for x in sys.argv[1:] if not x.startswith("-")], **kwargs)
if os.path.exists(config):
os.remove(config)