Skip to content

Commit

Permalink
Truncate TLS common name to 64 characters (#318)
Browse files Browse the repository at this point in the history
Fixes uncaught exception caused by changes in #317

https://warthogs.atlassian.net/browse/DPE-5411
  • Loading branch information
carlcsaposs-canonical authored Sep 9, 2024
1 parent f4cbbef commit bd2f317
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 12 deletions.
11 changes: 0 additions & 11 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion src/relations/tls.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,12 @@ def _generate_csr(self, key: bytes) -> bytes:
extra_hosts, extra_ips = self._charm.get_all_k8s_node_hostnames_and_ips()
return tls_certificates.generate_csr(
private_key=key,
subject=socket.getfqdn(),
# X.509 CommonName has a limit of 64 characters
# (https://github.com/pyca/cryptography/issues/10553)
subject=socket.getfqdn()[:64],
organization=self._charm.app.name,
sans_dns=[
socket.getfqdn(),
unit_name,
f"{unit_name}.{self._charm.app.name}-endpoints",
f"{unit_name}.{self._charm.app.name}-endpoints.{self._charm.model_service_domain}",
Expand Down

0 comments on commit bd2f317

Please sign in to comment.