File tree Expand file tree Collapse file tree 2 files changed +18
-6
lines changed Expand file tree Collapse file tree 2 files changed +18
-6
lines changed Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ get-inserted-data:
16
16
get-session-ssl-cipher :
17
17
description : Get ssl ciphers.
18
18
params :
19
- use_ssl :
19
+ use-ssl :
20
20
type : string
21
21
enum :
22
22
- " enabled"
Original file line number Diff line number Diff line change @@ -290,13 +290,25 @@ def _get_inserted_data(self, event: ActionEvent) -> None:
290
290
event .set_results ({"data" : self .app_peer_data .get (RANDOM_VALUE_KEY , "empty" )})
291
291
292
292
def _get_session_ssl_cipher (self , event : ActionEvent ) -> None :
293
- """Get the SSL cipher used by the session."""
293
+ """Get the SSL cipher used by the session.
294
+
295
+ This is useful to check that the connection is (un)encrypted.
296
+ The action has a `use-ssl` parameter that can be used to disable SSL.
297
+ """
294
298
if not self ._database_config :
295
- return event .set_results ({"cipher" : "empty " })
299
+ return event .set_results ({"cipher" : "noconfig " })
296
300
297
- with MySQLConnector (self ._database_config ) as cursor :
298
- cursor .execute ("SHOW SESSION STATUS LIKE 'Ssl_cipher'" )
299
- cipher = cursor .fetchone ()[1 ]
301
+ config = self ._database_config .copy ()
302
+ if event .params .get ("use-ssl" ) == "disabled" :
303
+ config ["ssl_disabled" ] = True
304
+
305
+ try :
306
+ with MySQLConnector (config ) as cursor :
307
+ cursor .execute ("SHOW SESSION STATUS LIKE 'Ssl_cipher'" )
308
+ cipher = cursor .fetchone ()[1 ]
309
+ except Exception :
310
+ logger .exception ("Unable to get the SSL cipher" )
311
+ cipher = "error"
300
312
301
313
event .set_results ({"cipher" : cipher })
302
314
You can’t perform that action at this time.
0 commit comments