Home > Net >  Query on upload to s3 bucket NodeJS
Query on upload to s3 bucket NodeJS

Time:09-07

I have one doubt about the s3 bucket; while uploading data to the s3 bucket using the upload function from aws-sdk in NodeJS, is data uploaded securely using TLS?

CodePudding user response:

Node.js 12.0.0 and later use a minimum version of OpenSSL 1.1.1b, which supports TLS 1.3. The AWS SDK for JavaScript v3 defaults to use TLS 1.3 when available, but defaults to a lower version if required.

To get the version of TLS used by Node.js on your computer, start the Node shell and run the following commands, in order.

var tls = require("tls");
var tlsSocket = new tls.TLSSocket();
tlsSocket.getProtocol();

Source: https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/enforcing-tls.html

CodePudding user response:

You can enforce your bucket to accept only TLS connections by adding the following bucket policy,

{
  "Id": "ExamplePolicy",
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "AllowSSLRequestsOnly",
      "Action": "s3:*",
      "Effect": "Deny",
      "Resource": [
        "arn:aws:s3:::YOUR-BUCKET",
        "arn:aws:s3:::YOUR-BUCKET/*"
      ],
      "Condition": {
        "Bool": {
          "aws:SecureTransport": "false"
        }
      },
      "Principal": "*"
    }
  ]
}
  • Related