| |
@@ -5,6 +5,7 @@
|
| |
from dateutil.relativedelta import relativedelta
|
| |
import errno
|
| |
import fileinput
|
| |
+ import ipaddress
|
| |
import os
|
| |
import re
|
| |
import subprocess
|
| |
@@ -109,8 +110,8 @@
|
| |
builder = builder.add_extension(
|
| |
x509.BasicConstraints(ca=False, path_length=None), critical=True,
|
| |
)
|
| |
- # Add Subject Alternative Names for all our dnsnames:
|
| |
- subject_alt_names = [x509.DNSName(dnsname) for dnsname in dnsnames]
|
| |
+ # Add Subject Alternative Names for all our dnsnames/ips:
|
| |
+ subject_alt_names = [to_subject_alt_name(dnsname) for dnsname in dnsnames]
|
| |
builder = builder.add_extension(
|
| |
x509.SubjectAlternativeName(subject_alt_names), critical=False,
|
| |
)
|
| |
@@ -432,6 +433,11 @@
|
| |
fin.close()
|
| |
print('wrote %s - use this in the HTTP server config' % chain_path)
|
| |
|
| |
+ def to_subject_alt_name(addr):
|
| |
+ try:
|
| |
+ return x509.IPAddress(ipaddress.ip_address(addr))
|
| |
+ except:
|
| |
+ return x509.DNSName(addr)
|
| |
|
| |
def parse_args():
|
| |
parser = argparse.ArgumentParser(description=DESCRIPTION,
|
| |
In the future please catch the exact error here instead of using bare
except
clauses