File tree Expand file tree Collapse file tree 1 file changed +24
-21
lines changed Expand file tree Collapse file tree 1 file changed +24
-21
lines changed Original file line number Diff line number Diff line change @@ -328,27 +328,30 @@ def _get_server_certificate(self, event: ActionEvent) -> None:
328
328
"""Get the server certificate."""
329
329
certificate = "error"
330
330
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 ()
352
355
353
356
event .set_results ({"certificate" : certificate })
354
357
You can’t perform that action at this time.
0 commit comments