AxiosError: write EPROTO C0D7BC0EAE7F0000

huangapple go评论96阅读模式
英文:

AxiosError: write EPROTO C0D7BC0EAE7F0000

问题

我在尝试向端点发送POST请求时遇到了这个错误。我不知道该怎么办,实际上也找不到关于它的任何信息。你能帮助我吗?非常感谢!

以下是我的axios请求的样子:

const config = {
    headers: {
        accept: "*/*",
        "accept-language": "tr,en-US;q=0.9,en;q=0.8",
        "cache-control": "no-cache",
        "content-type": "application/x-www-form-urlencoded;charset=UTF-8",
        pragma: "no-cache",
        "sec-fetch-mode": "cors",
        "sec-fetch-site": "same-origin",
    },
};

const url =
    process.env.MODE === "TEST"
        ? "https://earsivportaltest.efatura.gov.tr/earsiv-services/assos-login"
        : "https://earsivportal.efatura.gov.tr/earsiv-services/assos-login";

const assoscmd = process.env.MODE === "TEST" ? "login" : "anologin";

const response = await axios.post(
    `${url}`,
    {
        assoscmd: assoscmd,
        userid: userId,
        sifre: password,
        sifre2: password,
        parola: 1,
    },
    config
);
return response.data;

以下是我的错误:

AxiosError: write EPROTO C0D7BC0EAE7F0000:error:0A000152:SSL routines:final_renegotiate:unsafe legacy renegotiation disabled:../deps/openssl/openssl/ssl/statem/extensions.c:922:

    at AxiosError.from (/mnt/D/Yedekler/30 Aralık/Belgeler/fatura/node_modules/axios/dist/node/axios.cjs:789:14)
    at RedirectableRequest.handleRequestError (/mnt/D/Yedekler/30 Aralık/Belgeler/fatura/node_modules/axios/dist/node/axios.cjs:2744:25)
    at RedirectableRequest.emit (node:events:513:28)
    at eventHandlers.<computed> (/mnt/D/Yedekler/30 Aralık/Belgeler/fatura/node_modules/follow-redirects/index.js:14:24)
    at ClientRequest.emit (node:events:513:28)
    at TLSSocket.socketErrorListener (node:_http_client:494:9)
    at TLSSocket.emit (node:events:513:28)
    at emitErrorNT (node:internal/streams/destroy:151:8)
    at emitErrorCloseNT (node:internal/streams/destroy:116:3)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
  syscall: 'write',
  code: 'EPROTO',
  errno: -71,
}
英文:

I'm getting this error while trying send a post request to an endpoint. I don't know what to do and actually couldn't find anything about it. Could you please help me? Thanks a lot!

Here is how my axios request looks like:

const config = {
    headers: {
      accept: "*/*",
      "accept-language": "tr,en-US;q=0.9,en;q=0.8",
      "cache-control": "no-cache",
      "content-type": "application/x-www-form-urlencoded;charset=UTF-8",
      pragma: "no-cache",
      "sec-fetch-mode": "cors",
      "sec-fetch-site": "same-origin",
    },
  };

  const url =
    process.env.MODE === "TEST"
      ? "https://earsivportaltest.efatura.gov.tr/earsiv-services/assos-login"
      : "https://earsivportal.efatura.gov.tr/earsiv-services/assos-login";

  const assoscmd = process.env.MODE === "TEST" ? "login" : "anologin";

  const response = await axios.post(
    `${url}`,
    {
      assoscmd: assoscmd,
      userid: userId,
      sifre: password,
      sifre2: password,
      parola: 1,
    },
    config
  );
  return response.data;

Here is my error:

AxiosError: write EPROTO C0D7BC0EAE7F0000:error:0A000152:SSL routines:final_renegotiate:unsafe legacy renegotiation disabled:../deps/openssl/openssl/ssl/statem/extensions.c:922:

    at AxiosError.from (/mnt/D/Yedekler/30 Aralık/Belgeler/fatura/node_modules/axios/dist/node/axios.cjs:789:14)
    at RedirectableRequest.handleRequestError (/mnt/D/Yedekler/30 Aralık/Belgeler/fatura/node_modules/axios/dist/node/axios.cjs:2744:25)
    at RedirectableRequest.emit (node:events:513:28)
    at eventHandlers.<computed> (/mnt/D/Yedekler/30 Aralık/Belgeler/fatura/node_modules/follow-redirects/index.js:14:24)
    at ClientRequest.emit (node:events:513:28)
    at TLSSocket.socketErrorListener (node:_http_client:494:9)
    at TLSSocket.emit (node:events:513:28)
    at emitErrorNT (node:internal/streams/destroy:151:8)
    at emitErrorCloseNT (node:internal/streams/destroy:116:3)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
  syscall: 'write',
  code: 'EPROTO',
  errno: -71,

答案1

得分: 3

对于一个旧问题的回答,但如果有人有类似的问题,可以稍微修改这里的答案来解决它。

需要添加以下内容:

const https = require('https');
const crypto = require('node:crypto');

然后像这样在配置中添加:

httpsAgent: new https.Agent({secureOptions: crypto.constants.SSL_OP_LEGACY_SERVER_CONNECT})

或者

httpsAgent: new https.Agent({secureOptions: crypto.constants.SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION}),

像这样修改你的配置:

const config = {
    headers: {
      ...
    },
    httpsAgent: new https.Agent({secureOptions: crypto.constants.SSL_OP_LEGACY_SERVER_CONNECT}),    
};

这将解决final_renegotiate:unsafe legacy renegotiation disabled:问题。了解更多关于node:crypto模块的OpenSSL选项,或者其他选项的SSL_OP_Flags

英文:

Replying to an old question, but if anyone has a similar problem it can be solved modifying the answer here slightly.

require the following :

const https = require('https');
const crypto = require('node:crypto');

then add

httpsAgent: new https.Agent({secureOptions: crypto.constants.SSL_OP_LEGACY_SERVER_CONNECT})

or

httpsAgent: new https.Agent({secureOptions: crypto.constants.SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION}),

to your config like this :

const config = {
    headers: {
      ...
    },
    httpsAgent: new https.Agent({secureOptions: crypto.constants.SSL_OP_LEGACY_SERVER_CONNECT}),    
  };

This will solve the final_renegotiate:unsafe legacy renegotiation disabled:. issue. Read more about OpenSSL options of the node:crypto module, or SSL_OP_FLags for other options.

huangapple
  • 本文由 发表于 2023年1月6日 19:23:51
  • 转载请务必保留本文链接:https://go.coder-hub.com/75030316.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定