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

本地运行Teams Toolkit TypeScript Bot遇SSL协商错误,求临时禁用方案

解决Node.js中SSL不安全旧版重新协商禁用的临时方案(本地运行)

针对你遇到的write EPROTO C0050000:error:0A000152:SSL routines:final_renegotiate:unsafe legacy renegotiation disabled错误,以下是几种本地运行时临时绕过限制的方法:

方法1:通过环境变量启用OpenSSL旧版兼容模式

在启动项目前,设置Node.js环境变量强制使用旧版OpenSSL提供方:

  • Windows(命令提示符):
    set NODE_OPTIONS=--openssl-legacy-provider
    npm start
    
  • Windows(PowerShell):
    $env:NODE_OPTIONS="--openssl-legacy-provider"
    npm start
    
  • Linux/macOS:
    NODE_OPTIONS=--openssl-legacy-provider npm start
    

方法2:修改Axios请求的SSL配置

直接在Axios请求中配置自定义HTTPS代理,允许旧版重新协商:

TypeScript示例

import axios from 'axios';
import https from 'https';
import constants from 'constants';

// 创建允许旧版SSL协商的代理
const legacySslAgent = new https.Agent({
  secureOptions: constants.SSL_OP_LEGACY_SERVER_CONNECT
});

// 在请求中使用该代理
axios.get('你的令牌获取接口URL', {
  httpsAgent: legacySslAgent
})
.then(res => {
  // 处理令牌响应
})
.catch(err => {
  // 处理错误
});

JavaScript示例

const axios = require('axios');
const https = require('https');
const constants = require('constants');

const legacySslAgent = new https.Agent({
  secureOptions: constants.SSL_OP_LEGACY_SERVER_CONNECT
});

axios.get('你的令牌获取接口URL', { httpsAgent: legacySslAgent })
.then(res => { /* 处理逻辑 */ })
.catch(err => { /* 错误处理 */ });

重要提醒

  • 以上方案仅适合本地调试临时使用,生产环境绝对不要启用这些配置,因为旧版SSL重新协商存在安全风险。
  • 长期解决方案应该是对接的令牌服务端升级SSL/TLS配置,支持现代安全的重新协商机制。

内容的提问来源于stack exchange,提问作者Alex Chiu

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.09 04:37:38