Created
March 19, 2017 12:08
an attempt to convert AWS IAM credentials to the SES sort as per the instructions found here: http://docs.aws.amazon.com/ses/latest/DeveloperGuide/smtp-credentials.html#Obtaining Amazon SES SMTP Credentials by Converting AWS Credentials
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def hash_IAM(user_password): | |
#http://docs.aws.amazon.com/ses/latest/DeveloperGuide/smtp-credentials.html | |
if DEBUG: debug_message("Hashing for IAM to SES values") | |
AWS_SECRET_ACCESS_KEY = user_password | |
AWS_MESSAGE = "SendRawEmail" | |
#in Python 2, str are bytes | |
signature = hmac.new( | |
key=AWS_SECRET_ACCESS_KEY, | |
#byte[] rawSignature = mac.doFinal(MESSAGE.getBytes()); | |
msg=AWS_MESSAGE, | |
digestmod=hashlib.sha256 | |
).digest() | |
signature = chr(2) + signature | |
signature = base64.b64encode(signature) | |
return signature |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment