Search code examples
javascriptamazon-web-servicesamazon-s3certificateself-signed

How to use my signed-certificate to generate pre-signed URL to object at Amazon S3


I'd like to generate secure pre-signed url for the objects stored in Amazon S3. After I call generatePresignedUrl function in the Java SDK by passing resource key and bucket name, it returns an URL whose format is like https://{bucketname}.amazonaws.com{key}?AWSAccessKeyId=AKIAJ2ZNsY7UUIH7XMQA&Expires=1510834637&Signature=mkRSZBMdf4kAqCQr%2FMLQ2BMMI86Q%3D

The returned URL is being accessed by XMLHttpRequest via JavaScript code. I'm doing simple GET request to my URL and I get the error ERR_INSECURE_RESPONSE in the web browser. The reason is that certificate used in data transfer is a user-signed certificate, that means not validated by certificate authority, so that's why browser refuses to get the resource. I'd like to use my signed certificate in resource access at Amazon S3 to prevent this error to come out. How can I instruct Amazon S3 to use my certificate rather than continue to use Amazon's unsecure user-signed certificate?

Greatly appreciated...


Solution

  • I found the error. It's because my bucket name contains dots, and because of that the browser recognized it as a different domain and did not validate the security certificate issued by Amazon.