aws-sdk-js-v3 icon indicating copy to clipboard operation
aws-sdk-js-v3 copied to clipboard

client use http protocol failed

Open uzengo opened this issue 1 year ago • 1 comments

Checkboxes for prior research

Describe the bug

our client code

        s3Client = new S3({
          region: 'xx',
          endpoint: 'http://abc.com:',
          disableHostPrefix: true,
          tls: false,
          credentials: {
            accessKeyId: accessKey,
            secretAccessKey: accessSecret,
            sessionToken: accessToken,
          },
        });
   
 const uploadParams = {
        Bucket: bucket,
        Key: halfPath,
        Body: file, // file from <input type="file">
      };
      const upload = new Upload({
        client: s3Client,
        params: uploadParams,
        queueSize: 4, // optional concurrency configuration
        partSize: 1024 * 1024 * 5, // optional size of each part
        leavePartsOnError: false, // optional manually handle dropped parts
      });
      console.log('==>zzzz11');

      upload.on('httpUploadProgress', (progress) => {
        console.log('==>progress', progress);
      });
      try {
        await upload.done();
      } catch (err) {
        console.log('==>444', err);
      }

when we use this code, our endpoint change to https, the config is no work!!!

image

SDK version number

"@aws-sdk/client-s3": "3.577.0" "@aws-sdk/lib-storage": "3.578.0"

Which JavaScript Runtime is this issue in?

React Native

Details of the browser/Node.js/ReactNative version

v16.18.0

Reproduction Steps

see code

Observed Behavior

change url protocol from http to https

Expected Behavior

use http endpoint

Possible Solution

No response

Additional Information/Context

No response

uzengo avatar May 17 '24 09:05 uzengo

Hi @uzengo - I'm sorry this fell off my radar.

The ERR_SSL_PROTOCOL_ERROR is an error that occurs when there is a problem with the SSL/TLS protocol negotiation during the connection establishment phase. This error typically occurs when the client and server cannot agree on a common SSL/TLS protocol version or cipher suite.

In your case, when you specify http://abc.com as the endpoint, you're attempting to make an unencrypted HTTP connection to the S3 service. However, AWS S3 requires secure connections over HTTPS, and it seems that the combination of your endpoint configuration and the use of the tls: false option causes the SSL/TLS protocol negotiation to fail.

By changing the endpoint to https://abc.com, you're explicitly specifying that the connection should be made over HTTPS, which resolves the SSL/TLS protocol negotiation issue.

If you need to use a custom endpoint for your S3 service, you should use the https protocol scheme and remove the tls: false option, as TLS (Transport Layer Security) is required for secure communication with AWS services. The correct configuration would be:

s3Client = new S3({
  region: 'xx',
  endpoint: 'https://abc.com',
  disableHostPrefix: true,
  credentials: {
    accessKeyId: accessKey,
    secretAccessKey: accessSecret,
    sessionToken: accessToken,
  },
});

Hope it helps, John

aBurmeseDev avatar Aug 06 '24 01:08 aBurmeseDev

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.

github-actions[bot] avatar Oct 13 '24 00:10 github-actions[bot]