AWS Signature Generator

Unanswered Question
May 9th, 2014
User Badges:

Am trying to create a VM in AWS using HTTP Query API in CPO. I need to send a script through UserData paramter. The parameter is base64 encoded and sent as a string. The script consists nearly 30 lines. When i pass the remaining query parameters and UserData to calculate the signature, the signature process runs for nearly 45minutes with no output. But if i reduce my script to around 10 lines, the signature gets created. I use the following shell script to calculate the signature,


$secret, $data, $awshost = $args

[Reflection.Assembly]::LoadWithPartialName("System.Security") | Out-Null

$params = $data.replace("%%","%")
$verb = "POST"
$url = "/"

$data = [String]::Format("{0}`n{1}`n{2}`n{3}", $verb, $awshost, $url, $params)

$encoder = New-Object System.Text.UTF8Encoding
$sha256 = New-Object System.Security.Cryptography.HMACSHA256
$sha256.Key = $encoder.GetBytes($secret)
$hmac = $sha256.ComputeHash($encoder.GetBytes($data))
$enc = [System.Convert]::ToBase64String($hmac)
$hash = [System.Uri]::EscapeDataString($enc)
$null = [Reflection.Assembly]::LoadWithPartialName("System.Web")
$hash = [System.Web.HttpUtility]::UrlEncode($enc)



Could anyone please suggest me any workaround for this? Is there any limitations of the length of characters to be used for UserData parameter?

  • 1
  • 2
  • 3
  • 4
  • 5
Overall Rating: 0 (0 ratings)


This Discussion

Related Content