Skip to content

Commit ac880ba

Browse files
committed
failing event
1 parent a353533 commit ac880ba

File tree

1 file changed

+24
-21
lines changed

1 file changed

+24
-21
lines changed

src/charm.py

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -328,27 +328,30 @@ def _get_server_certificate(self, event: ActionEvent) -> None:
328328
"""Get the server certificate."""
329329
certificate = "error"
330330
if not self._database_config:
331-
return event.set_results({"certificate": certificate})
332-
try:
333-
process = subprocess.run(
334-
[
335-
"openssl",
336-
"s_client",
337-
"-starttls",
338-
"mysql",
339-
"-connect",
340-
f"{self._database_config['host']}:{self._database_config['port']}",
341-
],
342-
capture_output=True,
343-
)
344-
# butchered stdout due non utf chars after the certificate
345-
raw_output = process.stdout[:2800].decode("utf8")
346-
matches = re.search(
347-
r"^(-----BEGIN C.*END CERTIFICATE-----[,\s])", raw_output, re.MULTILINE | re.DOTALL
348-
)
349-
certificate = matches.group(0)
350-
except Exception:
351-
pass
331+
event.fail()
332+
else:
333+
try:
334+
process = subprocess.run(
335+
[
336+
"openssl",
337+
"s_client",
338+
"-starttls",
339+
"mysql",
340+
"-connect",
341+
f"{self._database_config['host']}:{self._database_config['port']}",
342+
],
343+
capture_output=True,
344+
)
345+
# butchered stdout due non utf chars after the certificate
346+
raw_output = process.stdout[:2800].decode("utf8")
347+
matches = re.search(
348+
r"^(-----BEGIN C.*END CERTIFICATE-----[,\s])",
349+
raw_output,
350+
re.MULTILINE | re.DOTALL,
351+
)
352+
certificate = matches.group(0)
353+
except Exception:
354+
event.fail()
352355

353356
event.set_results({"certificate": certificate})
354357

0 commit comments

Comments
 (0)