Created
July 13, 2020 16:25
-
-
Save virtualhobbit/147147cf1af9fee5aa47e1bb58238464 to your computer and use it in GitHub Desktop.
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
// Hash the payload | |
attHashedPayload = CryptoEncoding.base64toHex(CryptoDigest.sha256(attBody)); | |
// Format the date | |
attAmzDate = System.getModule("com.hobbitcloud.aws.date").getAmzDate(new Date().toISOString()); | |
var canonicalUri = "/2013-04-01/hostedzone/" + attHostedZone + "/rrset"; | |
var canonicalQueryString = ""; | |
var canonicalHeaders = 'host:' + attUrl + '\n' + | |
'x-amz-content-sha256:' + attHashedPayload + '\n' + | |
'x-amz-date:' + attAmzDate + '\n' | |
attSignedHeaders = 'host;x-amz-content-sha256;x-amz-date'; | |
// Define the request | |
var canonicalRequest = attHttpRequestMethod + '\n' + canonicalUri + '\n' + canonicalQueryString + '\n' + canonicalHeaders + '\n' + attSignedHeaders + '\n' + attHashedPayload; | |
System.log("The canonical request is: " + '\n' + '\n' + canonicalRequest + '\n'); | |
// Hash the request | |
attCanonicalRequestHash = CryptoEncoding.base64toHex(CryptoDigest.sha256(canonicalRequest)); | |
System.log("The canonical request hash is: " + attCanonicalRequestHash); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment