【发布时间】:2011-01-27 15:13:15
【问题描述】:
我正在使用 Amazon AWS .NET SDK v1.2.1。
以下代码在对myBucket.more.https 的 DNS 查找失败后引发异常,这显然不是它应该查找的内容...
AmazonS3Config S3Config = new AmazonS3Config()
{
ServiceURL = "https://s3.amazonaws.com",
CommunicationProtocol = Amazon.S3.Model.Protocol.HTTPS,
};
using (AmazonS3 client = Amazon.AWSClientFactory.CreateAmazonS3Client(accessKey,secretKey, S3Config))
{
PutObjectRequest request = new PutObjectRequest();
using (MemoryStream ms = new MemoryStream(inputBytes))
{
request.WithBucketName("myBucket.more")
.WithKey(output.Name)
.WithInputStream(ms);
using (S3Response response = client.PutObject(request))
{
Log.Message("File Sent: " + output.Name);
}
}
}
如果我从 ServiceURL 的前面删除 https://,它会引发 Web 异常:
"The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel."
那么我应该如何让 SSL 工作?
到目前为止,我管理的唯一方法是使用以下方法,这是不安全的:
AmazonS3Config S3Config = new AmazonS3Config()
{
ServiceURL = "s3.amazonaws.com",
CommunicationProtocol = Amazon.S3.Model.Protocol.HTTP,
};
更新
如果我没有将自定义 S3Config 传递给 CreateAmazonS3Client,它仍然会失败:
"The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel."
"The remote certificate is invalid according to the validation procedure."
【问题讨论】:
标签: c# amazon-s3 amazon-web-services