Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added both LB IP and hostname to sans #391

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -1160,15 +1160,16 @@ def server_cert_sans_dns(self) -> List[str]:
assert isinstance(target, str), target # for type checker
return [target]

targets: List[str] = [target] if target else []
# This is an IP address. Try to look up the hostname.
with contextlib.suppress(OSError, TypeError):
name, _, _ = socket.gethostbyaddr(target) # type: ignore
# Do not return "hostname" like '10-43-8-149.kubernetes.default.svc.cluster.local'
if is_hostname(name) and not name.endswith(".svc.cluster.local"):
return [name]
targets.append(cast(str, name))

# If all else fails, we'd rather use the bare IP
return [target] if target else []
return targets
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a couple of test cases? I'm thinking:

  • When external_hostname is set, then the CSR should be for the external hostname.
  • When external_hostname is unset, then the CSR should be for the loadbalancer IP.



@functools.lru_cache
Expand Down
27 changes: 0 additions & 27 deletions tests/scenario/test_scheme.py

This file was deleted.

Loading