grpc错误SSL23_GET_SERVER_HELLO

时间:2018-03-15 13:46:54

标签: node.js ssl proxy dialogflow

使用Ubuntu 16.04在Vagrant VM中工作......

我以前能够使用Google的Dialogflow API检测到意图,但现在它在我的新VM中出现错误。

步骤

  1. 创建Dialogflow项目
  2. 下载应用程序凭据JSON
  3. npm i dialogflow
  4. export GOOGLE_APPLICATION_CREDENTIALS=/path/to/creds.json

    node -e '
    const dialogflow = require("dialogflow");
    const cli = new dialogflow.SessionsClient();
    const session = cli.sessionPath("df-project-id", "session-id");
    const request = { session, queryInput: { text: { text: "Hello" } } };
    cli.detectIntent(request).then(console.log, console.error);'
    
  5. 错误

    Auth error:Error: write EPROTO 140436597872448:error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol:../deps/openssl/openssl/ssl/s23_clnt.c:827
    

    调试

    证书位于默认位置/etc/ssl/certs/ca-certificates.crt,我知道NodeJS正在使用它们,因为NODE_EXTRA_CA_CERTS=/etc/ssl/certs/ca-certificates.crt ${df test above}说:

    (node:4067) Warning: Ignoring extra certs from '/etc/ssl/certs/ca-certificates.crt', load failed: error:0B07C065:x509 certificate routines:X509_STORE_add_cert:cert already in hash table
    

    我看到请求也使用了在环境变量中声明的经过身份验证的代理:

    http_proxy=http://user:pass@proxy:port
    HTTP_PROXY=http://user:pass@proxy:port
    https_proxy=http://user:pass@proxy:port
    HTTPS_PROXY=http://user:pass@proxy:port
    

    请求

    {
      "pathname": "https://www.googleapis.com/oauth2/v4/token",
      "nativeProtocols": {
        "http:": {
          "METHODS": [...],
          "STATUS_CODES": {...},
          "globalAgent": {
            "domain": {
              "domain": null,
              "_events": {},
              "_eventsCount": 1,
              "members": []
            },
            "_events": {},
            "_eventsCount": 1,
            "defaultPort": 80,
            "protocol": "http:",
            "options": {
              "path": null
            },
            "requests": {},
            "sockets": {},
            "freeSockets": {},
            "keepAliveMsecs": 1000,
            "keepAlive": false,
            "maxSockets": null,
            "maxFreeSockets": 256
          }
        },
        "https:": {
          "globalAgent": {
            "domain": {
              "domain": null,
              "_events": {},
              "_eventsCount": 1,
              "members": []
            },
            "_events": {},
            "_eventsCount": 1,
            "defaultPort": 443,
            "protocol": "https:",
            "options": {
              "path": null
            },
            "requests": {},
            "sockets": {},
            "freeSockets": {},
            "keepAliveMsecs": 1000,
            "keepAlive": false,
            "maxSockets": null,
            "maxFreeSockets": 256,
            "maxCachedSessions": 100,
            "_sessionCache": {
              "map": {},
              "list": []
            }
          }
        }
      },
      "host": "proxy.*.com",
      "port": "8080",
      "hostname": "proxy.*.com",
      "headers": {
        "Accept": "application/json, text/plain, */*",
        "Content-Type": "application/x-www-form-urlencoded",
        "User-Agent": "axios/0.18.0",
        "Content-Length": 734,
        "host": "www.googleapis.com",
        "Proxy-Authorization": "Basic *hash*"
      },
      "method": "post",
      "path": "https://www.googleapis.com/oauth2/v4/token",
      "maxBodyLength": 10485760,
      "maxRedirects": 21,
      "protocol": "https:",
      "_defaultAgent": {
        "domain": {
          "domain": null,
          "_events": {},
          "_eventsCount": 1,
          "members": []
        },
        "_events": {},
        "_eventsCount": 1,
        "defaultPort": 443,
        "protocol": "https:",
        "options": {
          "path": null
        },
        "requests": {},
        "sockets": {},
        "freeSockets": {},
        "keepAliveMsecs": 1000,
        "keepAlive": false,
        "maxSockets": null,
        "maxFreeSockets": 256,
        "maxCachedSessions": 100,
        "_sessionCache": {
          "map": {},
          "list": []
        }
      }
    }
    

1 个答案:

答案 0 :(得分:1)

安全小组在没有任何通知的情况下阻止googleapis.com域名...我被误导认为该问题是由于我的新Vagrant虚拟机配置错误造成的。