You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Node.js 18 Lambda运行时OpenSSL证书迁移问题及方案咨询

Node.js 16 迁移至 Node.js 18 Lambda 时的证书问题咨询

我正在将多个Lambda函数从Node.js 16运行时迁移至Node.js 18,期间遇到证书相关问题。我们通过创建https.Agent()并传入配置发起HTTP请求,其中pfx属性为p12证书的缓冲区,代码如下:

const options = {
    pfx: certificate,
    passphrase: 'test',
    rejectUnauthorized: true,
};

const sslConfiguredAgent = new https.Agent(options);

经排查,问题与Node核心库中的OpenSSL相关,我尝试了两种临时解决方案但均失败:

  • 在Lambda环境变量中设置NODE_OPTIONS=--openssl-legacy-provider,导致Lambda初始化阶段出现"Unable to load Legacy Provider"错误;
  • 通过AWS_LAMBDA_EXEC_WRAPPER指定路径为/opt/data/wrapper的包装脚本,设置环境变量后执行Lambda,初始化预置并发时出现FUNCTION_ERROR_INIT_FAILURE错误。包装脚本内容如下:
#!/bin/bash

args=("$@")

export NODE_OPTIONS="--openssl-legacy-provider"

exec "${args[@]}"

咨询问题

  1. Node.js 18 Lambda运行时是否限制使用OpenSSL legacy provider?
  2. 该包装脚本是否有优化空间以解决问题?
  3. 有无其他方法可绕过此问题,成功在https.Agent()中传入pfx属性以避免"Error: unsupported at configSecureContext (node:internal/tls/secure-context:278:15)"错误?

内容的提问来源于stack exchange,提问作者Ivan Quesada

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.29 08:32:32