Amazon S3发布SSL以使用c#sdk

Tim*_*Tim 8 c# amazon-s3 amazon-web-services

我正在使用Amazon 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);
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

如果我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,
};
Run Code Online (Sandbox Code Playgroud)

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."

Geo*_*ord 7

ServiceUrl应该S3.amazonaws.com没有https://前面的.这是默认设置为是HTTPSCommunication协议.这就是为什么当您不手动设置设置时会出现相同的错误.

更新

如果要使用HTTPS,则EU桶不能在名称中包含句点(.).