简体   繁体   English

docker 在忽略 TLS 未授权 0 后仍然返回自签名 SSL 证书错误

[英]docker still return self-signed SSL cert error after ignore the TLS unauthorized 0

I am working on a POC for the nodejs container to call another IP's web application for testing.我正在为 nodejs 容器开发 POC,以调用另一个 IP 的 web 应用程序进行测试。 The application working fine in the local development env, and I deployed the app on SUSE15 for the final testing.该应用程序在本地开发环境中运行良好,我将应用程序部署在 SUSE15 上进行最终测试。 The api would like to call: api 想拨打:

const httpsAgent = new https.Agent({
  rejectUnauthorized: false,
})
axios.defaults.httpsAgent = httpsAgent;

class ansibleService {
  public async findJobStatusById(jobId: number){
try{
  let res = await axios.get(URL+'/api/v2/jobs/'+jobId ,{headers: {'Authorization': 'Basic '+basicAuth}}, {httpsAgent});
  console.log("status code: ", res.status)
  console.log(res.data);
  return res.data
}catch(err){
  console.log(err)
  return err
}

The app was built, however, the API call is not working and returns 503 error该应用程序已构建,但是 API 调用不起作用并返回 503 错误

Error: Request failed with status code 503\n    at createError (/app/node_modules/axios/lib/core/createError.js:16:15)\n    at settle (/app/node_modules/axios/lib/core/settle.js:17:12)\n    at IncomingMessage.handleStreamEnd (/app/node_modules/axios/lib/adapters/http.js:293:11)\n    at IncomingMessage.emit (events.js:327:22)\n    at endReadableNT (_stream_readable.js:1327:12)\n    at processTicksAndRejections (internal/process/task_queues.js:80:21

Coz it just a POC, i am trying to ignore the TLS cert and adding the NODE_TLS_REJECT_UNAUTHORIZED=0 and rejectUnauthorized: false, in side the code.因为它只是一个 POC,我试图忽略 TLS 证书并在代码中添加NODE_TLS_REJECT_UNAUTHORIZED=0rejectUnauthorized: false,

As the result, the app is still returning error 503 with details:结果,该应用程序仍然返回错误 503,其中包含详细信息:

  '</head><body id="ERR_SECURE_CONNECT_FAIL">\n' +
  '<div id="titles">\n' +
  '<h1>ERROR</h1>\n' +
  '<h2>The requested URL could not be retrieved</h2>\n' +
  '</div>\n' +
  '<hr>\n' +
  '\n' +
  '<div id="content">\n' +
  '<p>The following error was encountered while trying to retrieve the URL: <a href="https://10.194.113.123/api/v2/jobs/11507">https://10.194.113.123/api/v2/jobs/11507</a></p>\n' +
  '\n' +
  '<blockquote id="error">\n' +
  '<p><b>Failed to establish a secure connection to 10.194.113.123</b></p>\n' +
  '</blockquote>\n' +
  '\n' +
  '<div id="sysmsg">\n' +
  '<p>The system returned:</p>\n' +
  '<blockquote id="data">\n' +
  '<pre>(71) Protocol error (TLS code: X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT)</pre>\n' +
  '<p>Self-signed SSL Certificate: /CN=abc.corpdev.com</p>\n' +
  '</blockquote>\n' +
  '</div>\n' +
  '\n' +
  '<p>This proxy and the remote host failed to negotiate a mutually acceptable security settings for handling your request. It is possible that the remote host does not support secure connections, or the proxy is not satisfied with the host security credentials.</p>\n' 

Is that any config missed/incorrect on the docker build/run? docker 构建/运行时是否有任何配置遗漏/不正确? Please let me know where am i incorrect for the deployment if have如果有,请让我知道我在哪里部署不正确

Thanks!!!!谢谢!!!!

You're passing httpsAgent as an additional argument, but it should be placed in the request config object:您将httpsAgent作为附加参数传递,但它应该放在请求配置 object 中:

let res = await axios.get(URL+'/api/v2/jobs/'+jobId, {
 headers: {
   'Authorization': 'Basic '+basicAuth
 },
 httpsAgent
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 通过Node.js使用自签名证书的SSL - SSL using self-signed cert over Node.js iOS使用自签名TLS / SSL证书连接不起作用 - iOS connect with self-signed TLS/SSL certificate not working 节点 TLS 套接字:DEPTH_ZERO_SELF_SIGNED_CERT 错误 - Node TLS socket : DEPTH_ZERO_SELF_SIGNED_CERT error SSL 自签名证书上的 Chrome (net::ERR_CERT_COMMON_NAME_INVALID) 错误 - Chrome (net::ERR_CERT_COMMON_NAME_INVALID) errors on SSL self-signed certificate 无法信任来自 Node.js 中 IIS Express 的自签名 SSL 证书 - Unable to trust a self-signed SSL cert from IIS Express in Node.js 为本地主机创建一个受信任的自签名 SSL 证书(用于 Express/Node) - create a trusted self-signed SSL cert for localhost (for use with Express/Node) 具有自签名证书颁发机构的Nodejs TLS - Nodejs TLS with self-signed Certificate Authority 如何为开发/生产环境使用 Webpack 处理自签名 SSL/TLS.pem 文件的移动? - How to handle moving of self-signed SSL/TLS .pem files with Webpack for dev/prod environments? 使用 https.request 忽略 node.js 中无效的自签名 ssl 证书? - Ignore invalid self-signed ssl certificate in node.js with https.request? 配置自签名证书以使用 node,js - Config Self-Signed Cert to work with node,js
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM