我正在使用亚马逊 AWS .NET SDK v1.2.1。
以下代码在 DNS 查找失败后引发异常myBucket.more.https
这显然不是它应该寻找的......
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);
}
}
}
如果我删除https://
从 ServiceURL 的前面,它会抛出一个 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,
};
UPDATE
如果我不将自定义 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."