Skip to content

Commit

Permalink
Resolved apel#160
Browse files Browse the repository at this point in the history
now checks wether the host cert is the same as server cert for sender
if it is then an error message is given

added sender_failed = True to an exception to properly show it failed
  • Loading branch information
Will-Cross1 authored and tofu-rocketry committed Apr 10, 2024
1 parent 6440602 commit 34e16d4
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions ssm/agents.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,12 @@ def run_sender(protocol, brokers, project, token, cp, log):
host_dn = get_certificate_subject(_from_file(host_cert))
log.info('Messages will be signed using %s', host_dn)

if server_cert == host_cert:
raise Ssm2Exception(
"server certificate is the same as host certificate in config file. "
"Do you really mean to encrypt messages with this certificate?"
)

sender = Ssm2(brokers,
cp.get('messaging', 'path'),
path_type=path_type,
Expand All @@ -246,6 +252,7 @@ def run_sender(protocol, brokers, project, token, cp, log):
except (Ssm2Exception, CryptoException) as e:
print('SSM failed to complete successfully. See log file for details.')
log.error('SSM failed to complete successfully: %s', e)
sender_failed = True
except Exception as e:
print('SSM failed to complete successfully. See log file for details.')
log.exception('Unexpected exception in SSM. See traceback below.')
Expand Down

0 comments on commit 34e16d4

Please sign in to comment.