I have completed the base64 encoding of the UserData. Am using a utility tool which encodes the data to a base64 format. I invoke the tool through a powershell command of CPO process. But when ipass this to calculate the AWS signature, its running for nearly 30 minutes without any output. When i reduce my UserData length to around 4 to 5 lines, it calculates the signature perfectly. Am using a powershell script to calculate the signature. The same below,
$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)
$hash.toString()
Could you please suggest how to resolve this. Is there any other command to create the signature?