【发布时间】:2014-09-22 04:33:16
【问题描述】:
我收到此错误:
<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:6c3fc9a8-cdf6-4874-a141-10282b709022 Time:2014-07-30T10:48:43.8634735Z
</Message>
<AuthenticationErrorDetail>
Signature did not match. String to sign used was rwl 2014-07-31T04:48:20Z /acoustie/$root 2014-02-14
</AuthenticationErrorDetail>
</Error>
当我生成一个 sas(共享访问签名)然后将该 sas 粘贴到容器 uri 的末尾时,我得到了它到浏览器中。这是生成的 sas 的完整地址:
https://acoustie.blob.core.windows.net/mark?sv=2014-02-14&sr=c&sig=E6w%2B3B8bAXK8Lhvvr62exec5blSxsA62aSWAg7rmX4g%3D&se=2014-07-30T13%3A30%3A14Z&sp=rwl
我搜索了 SO 和 Google 并尝试了很多组合,据我所知,我做的一切都是正确的,我知道我不是,我只是看不到它......真的希望有人能帮助:-\
需要明确的是,我是在容器上生成 sas,而不是在特定的 blob 上,也不是在根容器上。对 Blob 的访问定义为公共 Blob。我的最终目标是简单地允许使用 sas 写入容器,同时“调试”我已将大部分权限添加到 SharedAccessBlobPolicy。
我尝试在容器名称的beginning and ending 处添加一个\。没有变化。
这是我用来生成 sas 的代码:
var blobClient = storageAccount.CreateCloudBlobClient();
//Get a reference to the blob container
var container = blobClient.GetContainerReference(containerName);
// Do not set start time so the sas becomes valid immediately.
var sasConstraints = new SharedAccessBlobPolicy
{
SharedAccessExpiryTime = DateTime.UtcNow.AddMinutes(30),
Permissions = SharedAccessBlobPermissions.Write
| SharedAccessBlobPermissions.Read
| SharedAccessBlobPermissions.List,
};
var sasContainerToken = container.GetSharedAccessSignature(sasConstraints);
//Return the URI string for the container, including the SAS token.
var sas = string.Format("{0}{1}", container.Uri.AbsoluteUri, sasContainerToken);
Logger.Debug("SAS: {0}", sas);
return sas;
它会生成一个签名,但它似乎不是一个有效的签名。
我尝试了不同的容器,更改了访问策略,有无开始时间,将到期时间延长到从现在起 12 小时以上(我在 UTC+10 时区),这似乎无关紧要我更改它会导致相同的“签名不匹配”错误。
我什至尝试过使用旧版本的“WindowsAzure.Storage”,所以我现在尝试了 4.2 和 4.1。甚至在不同的浏览器中尝试了 uri,确实不应该有所作为,但是嘿......
非常感谢任何建议:-)
【问题讨论】:
-
您是否尝试使用此 SAS URL 列出 blob?
-
我只是不想看到 AuthenticationFailed 错误。我认为它“应该”显示 blob 列表,尽管我已授予它 List 权限。
-
我没有使用 SAS 访问我的容器。为什么我得到同样的错误?刚刚更新了我设备上的时区并开始工作。问题是我不想依赖时区。我能做什么?
标签: c# azure azure-blob-storage