I am using coldfusion webservice for my custom skill. Docs here
We're successfully extracting the public key, checking the start/end dates of the certificate, verifying that echo-api.amazon.com is the subject of the certificate, and verifying the chain of trust (by using OpenSSL command line functions).
But we're stuck at the point where the Amazon documentation says to "Use the public key extracted from the signing certificate to decrypt the encrypted signature to produce the asserted hash value."
here is my code -
<cfexecute name="D:\openssl.exe"
arguments="x509 -noout -pubkey -in D:\web\alexa\cert\echo.pem"
variable="local.cert.OpenSSL_Pubkey"
timeout="120" >
</cfexecute>
<cffile action="write"
file="D:\web\alexa\cert\keys\pubkey.key"
output="#local.cert.OpenSSL_Pubkey#" nameconflict="makeunique">
<cfset encryptedSign = binaryEncode( ToBinary( signature ) , "hex")>
<cffile action="write"
file="D:\web\alexa\cert\keys\pubkey.sig"
output="#encryptedSign#" nameconflict="makeunique">
<cfset assertedHash = Decrypt(encryptedSign, local.cert.OpenSSL_Pubkey)>
<cffile action="write"
file="D:\web\alexa\cert\keys\assertedHash.txt"
output="#assertedHash#" nameconflict="makeunique">
<cfset deriveddHash = Hash(toString( getHttpRequestData().content ),"SHA-1")>
<cffile action="write"
file="D:\web\alexa\cert\keys\deriveddHash.txt"
output="#deriveddHash#" nameconflict="makeunique">
I think, the issue is on coldfusion decrypt logic where i get assertedHash value. Unfortunately this gives me binary rubbish such as: 0!0 +p��(}%