Skip to content

Commit

Permalink
Fix issue with Testcase in django-pyas2 - test_partner_missing_error …
Browse files Browse the repository at this point in the history
…as sender may be None.
  • Loading branch information
chadgates committed Nov 21, 2024
1 parent c97ec7a commit 7ad644c
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions pyas2lib/as2.py
Original file line number Diff line number Diff line change
Expand Up @@ -918,12 +918,18 @@ def build(
)
del signature["MIME-Version"]

signed_data = sign_message(
canonicalize(self.payload),
self.digest_alg,
message.receiver.sign_key,
message.sender.sign_alg,
)
kwargs = {
"data_to_sign": canonicalize(self.payload),
"digest_alg": self.digest_alg,
"sign_key": message.receiver.sign_key,
}

# Include the sender sign algo only if sender is provided.
if message.sender:
kwargs["sign_alg"] = message.sender.sign_alg

signed_data = sign_message(**kwargs)

signature.set_payload(signed_data)
encoders.encode_base64(signature)

Expand Down

0 comments on commit 7ad644c

Please sign in to comment.