2011-01-27 35 views
8

我正在使用Amazon AWS .NET SDK v1.2.1。Amazon S3問題獲得SSL與c#sdk配合使用

下面的代碼未能通過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); 
     } 
    } 
} 

如果我從它拋出的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, 
}; 

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.":仍在與失敗

回答

6

ServiceUrl應該是S3.amazonaws.com,前面沒有https://。這是Communication協議的默認設置,如HTTPS。這就是爲什麼當你沒有手動設置設置時你會得到相同的錯誤。如果你想使用HTTPS

更新

歐盟桶不能包含在名稱句號(。)。

+0

該存儲桶是在幾個小時前創建的,如果關閉SSL,它可以完美工作。使用默認配置,我得到:「底層連接已關閉:無法建立SSL/TLS安全通道的信任關係。根據驗證過程,遠程證書無效。」 – Tim 2011-01-27 16:00:42