I am trying to upload my files to DO Spaces but I keep getting this error:
The remote certificate is invalid according to the validation procedure.
I am adapting my code that I was using to upload to AWS S3:
try
{
var config = new AmazonS3Config();
config.ServiceURL = DigitalOceanUrl;
var bucket = BucketName;
var client = new AmazonS3Client(AccessKey, AccessSecret, config);
FileInfo fi = new FileInfo(FilePath);
byte[] fileBytes = System.IO.File.ReadAllBytes(FilePath);
var fileName = FileName;
PutObjectResponse response = null;
using (var stream = new MemoryStream(fileBytes))
{
var request = new PutObjectRequest
{
BucketName = bucket,
Key = LowerCasePathIncludingFolderName + "/" + fileName,
ContentType = MimeTypesMap.GetMimeType(System.IO.Path.GetFileName(FilePath)),
CannedACL = S3CannedACL.Private,
InputStream = stream,
};
response = await client.PutObjectAsync(request);
stream.Close();
};
if (response.HttpStatusCode == System.Net.HttpStatusCode.OK)
{
return new S3ResponseViewModel
{
Status = System.Net.HttpStatusCode.OK,
Message = fileName + " Uploaded"
};
}
else
{
return new S3ResponseViewModel
{
Status = System.Net.HttpStatusCode.InternalServerError,
Message = fileName + " was not Uploaded"
};
}
}
catch(Exception e)
{
return new S3ResponseViewModel
{
Status = System.Net.HttpStatusCode.InternalServerError,
Message ="File was not Uploaded"
};
}
Am I missing something? I have checked and the Service URL is the same one that was provided by DO.
Edit 1:
I realized if I added config.RegionEndpoint = Amazon.RegionEndpoint.APSoutheast1, the error changes to:
The AccessKey doesn’t exist in our records
How do I determine the region for DigitalOcean?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Enter your email to get $200 in credit for your first 60 days with DigitalOcean.
New accounts only. By submitting your email you agree to our Privacy Policy.
I think I finally figured this out… Don’t set the Region and set the ServiceURL to just the base spaces url, so instead of https://some-bucket.nyc3.digitaloceanspaces.com, set it to https://nyc3.digitaloceanspaces.com