make alt names attributes on Spawner instead of args to create_certs

This commit is contained in:
Min RK
2018-10-02 11:21:38 +02:00
parent 94bb9ed00d
commit febb7c32c1

View File

@@ -696,7 +696,22 @@ class Spawner(LoggingConfigurable):
""" """
return s.format(**self.template_namespace()) return s.format(**self.template_namespace())
async def create_certs(self, alt_names=None, override=False): ssl_alt_names = List(
Unicode(),
config=True,
help="""List of SSL alt names
May be set in config if all spawners should have the same value(s),
or set at runtime by Spawner that know their names.
"""
)
ssl_alt_names_include_local = Bool(
True,
config=True,
help="""Whether to include DNS:localhost, IP:127.0.0.1 in alt names""",
)
async def create_certs(self):
"""Create and set ownership for the certs to be used for internal ssl """Create and set ownership for the certs to be used for internal ssl
Keyword Arguments: Keyword Arguments:
@@ -726,9 +741,9 @@ class Spawner(LoggingConfigurable):
""" """
from certipy import Certipy from certipy import Certipy
default_names = ["DNS:localhost", "IP:127.0.0.1"] default_names = ["DNS:localhost", "IP:127.0.0.1"]
alt_names = alt_names or [] alt_names = self.ssl_alt_names or []
if not override: if self.ssl_alt_names_include_local:
alt_names = default_names + alt_names alt_names = default_names + alt_names
common_name = self.user.name or 'service' common_name = self.user.name or 'service'