与AWS SDK Node.js的定制S3服务器的自签名证书错误
我试图连接到定制S3服务器(基于AWS没有),并创建桶。
使用下面的代码在Python的工作原理:
session = boto3.session.Session()
s3res = session.resource(service_name='s3',
use_ssl=True,
verify=False,
aws_access_key_id='xxx',
aws_secret_access_key='xxx',
endpoint_url='https://xxx',
config=botocore_client_config)
然而,在Node.js的下面的代码不会:
const AWS = require("aws-sdk");
const https = require('https');
const S3 = new AWS.S3({
accessKeyId: 'xxx',
secretAccessKey: 'xxx',
endpoint: 'https://xxx/',
s3ForcePathStyle: true,
httpOptions: {
agent: new https.Agent({ rejectUnauthorized: false })
}
});
事实上,它试图创建桶时,将导致以下错误:
{ NetworkingError: Protocol "http:" not supported. Expected "https:"
at new ClientRequest (_http_client.js:109:11)
at Object.request (http.js:41:10)
at features.constructor.handleRequest (/home/ec2-user/s3-tests/node_modules/aws-sdk/lib/http/node.js:42:23)
如果我删除自定义HTTPS代理,我收到以下错误:
{ Error: self signed certificate
at TLSSocket.onConnectSecure (_tls_wrap.js:1048:34)
此外,设置process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
于事无补。
貌似节点版本缺少从S3选项sslEnabled: false
...
与AWS SDK Node.js的定制S3服务器的自签名证书错误
我试图连接到定制S3服务器(基于AWS没有),并创建桶。
使用下面的代码在Python的工作原理:
session = boto3.session.Session()
s3res = session.resource(service_name='s3',
use_ssl=True,
verify=False,
aws_access_key_id='xxx',
aws_secret_access_key='xxx',
endpoint_url='https://xxx',
config=botocore_client_config)
然而,在Node.js的下面的代码不会:
const AWS = require("aws-sdk");
const https = require('https');
const S3 = new AWS.S3({
accessKeyId: 'xxx',
secretAccessKey: 'xxx',
endpoint: 'https://xxx/',
s3ForcePathStyle: true,
httpOptions: {
agent: new https.Agent({ rejectUnauthorized: false })
}
});
事实上,它试图创建桶时,将导致以下错误:
{ NetworkingError: Protocol "http:" not supported. Expected "https:"
at new ClientRequest (_http_client.js:109:11)
at Object.request (http.js:41:10)
at features.constructor.handleRequest (/home/ec2-user/s3-tests/node_modules/aws-sdk/lib/http/node.js:42:23)
如果我删除自定义HTTPS代理,我收到以下错误:
{ Error: self signed certificate
at TLSSocket.onConnectSecure (_tls_wrap.js:1048:34)
此外,设置process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
于事无补。
貌似节点版本缺少从S3选项sslEnabled: false
...