Skip to content

Commit

Permalink
Add handling of msgs with no blankline before body
Browse files Browse the repository at this point in the history
Add try...except to catch ValueErrors raised when there's no blank line
beween header and body of an otherwise valid signed message. Raising a
CryptoException means that the message will be rejected nicely in
Ssm2.on_message.
  • Loading branch information
tofu-rocketry committed May 14, 2018
1 parent 645eb46 commit 46cd7a5
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion ssm/crypto.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,10 @@ def verify(signed_text, capath, check_crl):

# SMIME header and message body are separated by a blank line
lines = message.strip().splitlines()
blankline = lines.index('')
try:
blankline = lines.index('')
except ValueError:
raise CryptoException('No blank line between message header and body')
headers = '\n'.join(lines[:blankline])
body = '\n'.join(lines[blankline + 1:])
# two possible encodings
Expand Down

0 comments on commit 46cd7a5

Please sign in to comment.