plainheart / bing-translate-api

A simple and free API for Bing & Microsoft Translator for Node.js
https://github.com/plainheart/bing-translate-api
MIT License
156 stars 28 forks source link

v2.9.1 'RequestError' code:'ERR_TLS_CERT_ALTNAME_INVALID' #23

Closed 1103442828 closed 1 year ago

1103442828 commented 1 year ago

2.9.1翻译出错,极少次成功。 在源代码调试中定位到 “fetchGlobalConfig” 函数 catch (e) { console.error('failed to fetch global config', e) throw e } 此处抛出错误。 以下是 catch e对象的部分内容:

{
code:'ERR_TLS_CERT_ALTNAME_INVALID',
name:'RequestError',
timings: {start: 1684146043656, socket: 1684146043662, lookup: 1684146043663, connect: 1684146043765, secureConnect: undefined, …},
message: 'Hostname/IP does not match certificate's altnames: Host: cn.bing.com. is not in the cert's altnames: DNS:*.media.microsoftstream.com, DNS:*.azureedge.net, DNS:*.origin.mediaservices.windows.net, DNS:*.streaming.mediaservices.windows.net',

code: 'ERR_TLS_CERT_ALTNAME_INVALID'
name: 'RequestError'
timings: {start: 1684146043656, socket: 1684146043662, lookup: 1684146043663, connect: 1684146043765, secureConnect: undefined, …}
message: 'Hostname/IP does not match certificate's altnames: Host: cn.bing.com. is not in the cert's altnames: DNS:*.media.microsoftstream.com, DNS:*.azureedge.net, DNS:*.origin.mediaservices.windows.net, DNS:*.streaming.mediaservices.windows.net'

agent: undefined
allowGetBody: false
cache: undefined
cacheHeuristic: undefined
cacheOptions: {}
decompress: true
dnsCache: undefined
followRedirect: true
headers: {user-agent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) A…like Gecko) Chrome/110.0.0.0 Safari/537.36', accept-encoding: 'gzip, deflate, br'}
http2: false
https: undefined
ignoreCargoCult: undefined
ignoreInvalidCookies: false
immutableMinTimeToLive: undefined
isStream: false
maxRedirects: 10
method: 'GET'
password: ''
prefixUrl: () => prefixUrl
request: { 
requestUrl:'https://bing.com/translator'.}
responseType: 'text'
response: { url:'https://bing.com/translator', requestUrl:'https://bing.com/translator',statusCode:
301, statusMessage: 'Moved Permanently', ip:'204.79.197.200' }

}
plainheart commented 1 year ago

请使用最新版 2.9.1 验证是否仍存在此问题。

1103442828 commented 1 year ago

请使用最新版 2.9.1 验证是否仍存在此问题。

不好意思版本写错了,已更正,当前使用的就是最新版本

plainheart commented 1 year ago

@1103442828 抱歉我这边似乎无法复现,看起来像是跳转 cn 域名后 https 证书被认为有问题,我暂时也不太清楚为什么会那样,会不会是开启网络代理或者配置的 DNS 导致解析的 IP 或 CNAME 有问题?

1103442828 commented 1 year ago

@1103442828 抱歉我这边似乎无法复现,看起来像是跳转 cn 域名后 https 证书被认为有问题,我暂时也不太清楚为什么会那样,会不会是开启网络代理或者配置的 DNS 导致解析的 IP 或 CNAME 有问题?

感觉是这个原因,我换到家庭网络就没问题。 感谢回复!