节点 12 的 axios SSL 错误:SSL 例程:ssl_choose_client_version:不支持的协议 [英] axios SSL error with Node 12 : SSL routines:ssl_choose_client_version:unsupported protocol

查看:37
本文介绍了节点 12 的 axios SSL 错误:SSL 例程:ssl_choose_client_version:不支持的协议的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了 axios 和 Node 12 的问题.因为我不确定这个错误是否只与 axios 相关,所以我按照建议询问在 SO 上而不是在 axios 的 GitHub 上打开错误.

I’m running into an issue with axios and Node 12. As I’m not sure this error is only related to axios, I followed the advice to ask on SO rather than opening a bug on axios’ GitHub.

这是我要运行的代码:

const axios = require('axios')

axios({
  method: 'get',
  url: 'https://www.colisprive.com/moncolis/pages/detailColis.aspx?numColis=12345',
  responseType: 'text'
}).then((response) => {
  console.log(response)
})

此代码在节点 12 上失败并出现以下错误:

This code fails on Node 12 with following error :

Error: write EPROTO 140121214769024:error:1425F102:SSL routines:ssl_choose_client_version:unsupported protocol:../deps/openssl/openssl/ssl/statem/statem_lib.c:1929:

    at WriteWrap.onWriteComplete [as oncomplete] (internal/stream_base_commons.js:87:16)

针对 Node 11 运行的相同代码不会引发任何错误.

当我 curl -v 我得到这个:

*   Trying 91.208.224.32:443...
* TCP_NODELAY set
* Connected to www.colisprive.com (91.208.224.32) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
*   CAfile: none
  CApath: /etc/ssl/certs
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
* TLSv1.3 (IN), TLS handshake, Server hello (2):
* TLSv1.2 (IN), TLS handshake, Certificate (11):
* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
* TLSv1.2 (IN), TLS handshake, Server finished (14):
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
* TLSv1.2 (OUT), TLS change cipher, Change cipher spec (1):
* TLSv1.2 (OUT), TLS handshake, Finished (20):
* TLSv1.2 (IN), TLS handshake, Finished (20):
* SSL connection using TLSv1.2 / ECDHE-RSA-AES256-SHA384
* ALPN, server did not agree to a protocol
* Server certificate:
*  subject: serialNumber=391029345; jurisdictionC=FR; businessCategory=Private Organization; C=FR; postalCode=13290; ST=Bouches-du-Rh�ne; L=AIX EN PROVENCE; street=1330 AV J R G GAUTIER DE LA LAUZIERE; street=ZI MILLES EUROPARC PICHAURY; O=COLIS PRIVE SAS; OU=0002 391029345; CN=www.colisprive.com
*  start date: Sep  3 00:00:00 2018 GMT
*  expire date: Sep  2 23:59:59 2020 GMT
*  subjectAltName: host "www.colisprive.com" matched cert's "www.colisprive.com"
*  issuer: C=GB; ST=Greater Manchester; L=Salford; O=COMODO CA Limited; CN=COMODO RSA Extended Validation Secure Server CA
*  SSL certificate verify ok.
> GET /moncolis/pages/detailColis.aspx?numColis=12345 HTTP/1.1
> Host: www.colisprive.com
> User-Agent: curl/7.65.3
> Accept: */*
> 
* Mark bundle as not supporting multiuse
< HTTP/1.1 302 Found
< Cache-Control: private
< Content-Type: text/html; charset=utf-8
< Location: /moncolis/Default.aspx?numColis=12345&cp=
< Server: Microsoft-IIS/7.5
< Set-Cookie: ASP.NET_SessionId=eln3cq143d35lfj5tpqkkwcg; path=/; HttpOnly
< X-Powered-By: Colis Priv�
< Date: Fri, 24 Jan 2020 13:48:35 GMT
< Content-Length: 162
< 
<html><head><title>Object moved</title></head><body>
<h2>Object moved to <a href="/moncolis/Default.aspx?numColis=12345&amp;cp=">here</a>.</h2>
</body></html>
* Connection #0 to host www.colisprive.com left intact

如您所见,它提供了一个 302 Found 和一个指向另一个端点的 Location 标头.我同意它应该回答 301 Moved 以指示文档已移动,但事实并非如此,它由节点 11 上的 axios 按预期处理(在 <代码>位置标题).

As you can see, it gives a 302 Found with a Location header pointing to another endpoint. I agree it should answer a 301 Moved to indicate document has moved, but this is not the case and it is handled as expected by axios on Node 11 (fetching endpoint under Location header).

我看到 Node 12 现在默认包含 TLS 1.3,所以这可能与此有关......

I saw that Node 12 now includes TLS 1.3 as default, so this could be related to that…

此外,X-Powered-By 标头中有一个未知字符.

Also, there is an unknown character in X-Powered-By header.

我尝试过:

  • 使用始终回复 302 Foundexpress 服务器重现此问题:按预期工作
  • 使用 axios 获取另一个 .aspx 网页:按预期工作
  • reproduce this issue with an express server always replying 302 Found with same headers : works as expected
  • fetch another .aspx web page with axios : works as expected

推荐答案

问题不仅在于 axios,还在于 got.

The problem is not just with axios but with got as well.

Node.js 12 的默认 TLS 设置现在更加严格.该站点不处理 TLS v1.2.默认情况下,节点 12 需要 1.2.

Node.js 12's default TLS settings are stricter now. The site doesn't handle TLS v1.2. Node 12 by default need 1.2.

您可以在运行应用程序时通过命令行标志 (--tls-min-v1.0) 更改此设置.

You can change this via a command line flag (--tls-min-v1.0) when running your app.

类似的东西

node --tls-min-v1.0 app.js

这篇关于节点 12 的 axios SSL 错误:SSL 例程:ssl_choose_client_version:不支持的协议的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆