无法对启用了SSL的Amazon S3端点进行REST API调用。得到错误“根据验证过程,远程证书无效。”
我试图将证书密钥添加到X509store并使用AmazonS3Client调用Amazon S3
using (var store = new X509Store(StoreName.Root, StoreLocation.CurrentUser))
{
store.Open(OpenFlags.ReadWrite);
cert = new X509Certificate2(Convert.FromBase64String(CERT_KEY)); //Hard coded the cert base 64 key
store.Add(cert);
}
using (_s3Client = new AmazonS3Client("accessKey", "secretKey", _config))
{
ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) => true;
string serviceUrl = _s3Client.Config.DetermineServiceURL();
PutObjectRequest putObjectRequest = new PutObjectRequest();
putObjectRequest.BucketName = "test-https";
putObjectRequest.Key = filename;
using (Stream stream = new MemoryStream(Encoding.UTF8.GetBytes("This is a Test File")))
{
putObjectRequest.InputStream = stream;
response = _s3Client.PutObjectAsync(putObjectRequest).Result;
}
我在PutObjectAsync方法调用上收到SSL验证错误。任何帮助将不胜感激