我正在使用node-module basic-ftp,尝试通过TLS/ SSL建立安全连接。服务器使用通配符CA签名证书作为主机名。 我找不到以下错误代码的答案。
Connected to 1.1.1.1:21
< 220 Welcome to ftp.foo.com
> AUTH TLS
< 234 Using authentication type TLS
{ Error: unable to verify the first certificate
at TLSSocket.onConnectSecure (_tls_wrap.js:1051:34)
at TLSSocket.emit (events.js:189:13)
at TLSSocket._finishInit (_tls_wrap.js:633:8) code: 'UNABLE_TO_VERIFY_LEAF_SIGNATURE'
}
以下是示例代码:
const ftp = require("basic-ftp");
async establishFtpsConnection() {
const client = new ftp.Client();
client.ftp.verbose = true;
try {
await client.access({
host: "ftp.foo.com",
user: "bar",
password: "1234",
port: 21,
secure: true
});
const list = await client.list();
console.log(list);
} catch (err) {
console.log(err);
}
client.close();
}
注意:我正在尝试使其在我的生产环境中正常工作,所以禁用或拒绝未授权的访问不是我选择的选项。
process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = '0';
或者
rejectUnauthorized: false
.addFile(__dirname + '/ssl/01-cheap-ssl-intermediary-a.pem')
- M. Haenzi