【发布时间】:2017-03-01 11:47:00
【问题描述】:
我一直在查看 MSDN 文档、文章和堆栈溢出,但不确定是什么问题。
https://www.kaizenspark.com/blog/topic/mirthconnect
我一直在使用这篇文章尝试使用 Mirth Connect 连接到 Azure 队列存储。
Azure 授权是这样完成的:
importPackage(javax.crypto);
importPackage(javax.crypto.spec);
importPackage(org.apache.commons.codec.binary);
// Change the variables below to your actual account details
// Remember the queue name must be lower case or it will fail
var account = "devstoreaccount1";
var key = "Access key";
var path = "devstoreaccount1/myqueuename/messages";
// No changes below this line
var apiVersion = "2011-08-18";
var contentLength = String(tmp).length;
var gmtDateString = new Date().toGMTString();
var stringToSign =
"POST\n" + /*HTTP Verb*/
"\n" + /*Content-Encoding*/
"\n" + /*Content-Language*/
contentLength + "\n" + /*Content-Length*/
"\n" + /*Content-MD5*/
"text/xml; charset=UTF-8\n" + /*Content-Type*/
"\n" + /*Date*/
"\n" + /*If-Modified-Since */
"\n" + /*If-Match*/
"\n" + /*If-None-Match*/
"\n" + /*If-Unmodified-Since*/
"\n" + /*Range*/
/* CanonicalizedHeaders */
"x-ms-date:" + gmtDateString + "\n" +
"x-ms-version:" + apiVersion + "\n" +
/* CanonicalizedResource */
"/" + account + "/" + path;
var mac = Mac.getInstance("HmacSHA256");
mac.init(new SecretKeySpec(Base64.decodeBase64(key), mac.getAlgorithm()));
mac.update(java.lang.String(stringToSign).getBytes("UTF-8"));
var hmac = Base64.encodeBase64String(mac.doFinal());
connectorMap.put('Authorization', 'SharedKey ' + account + ':' + hmac);
connectorMap.put('x-ms-date', gmtDateString);
connectorMap.put('x-ms-version', apiVersion);
connectorMap.put('path', path);
除了输入我自己的帐户名、密钥和路径外,我没有进行任何更改。 根据此处的文档:https://msdn.microsoft.com/en-us/library/azure/dd179428.aspx#,stringToSign 似乎是正确的。
但是,我收到此错误:
ERROR MESSAGE: <?xml version="1.0" encoding="utf-8"?><Error><Code>AuthenticationFailed</Code><Message>Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature. RequestId:'id' Time:2016-10-19T17:24:51.6491513Z</Message><AuthenticationErrorDetail>The MAC signature found in the HTTP request 'key' is not the same as any computed signature. Server used following string to sign: 'POST 88 text/xml; charset=UTF-8 x-ms-date:Wed, 19 Oct 2016 17:24:50 GMT x-ms-version:2011-08-18 /accountname/queuename'.</AuthenticationErrorDetail></Error>
出于隐私考虑,我将请求 ID 更改为“密钥”和帐户名称以及队列名称,否则错误消息与显示给我的相同。任何帮助将不胜感激!
【问题讨论】:
-
你能说出你想做什么操作吗?看起来您正在尝试将消息添加到队列中,但想确定一下。另外,请确认您尝试使用存储模拟器而不是云存储帐户来执行此操作。
标签: javascript azure authentication azure-storage mirth