zoukankan      html  css  js  c++  java
  • Node.js使用https请求时,出现“SSL23_GET_SERVER_HELLO”错误

    Node.js程序改造成https请求,遇到了另外一个问题

    错误提示如下:

    SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure:../deps/openssl/openssl/ssl/s23_clnt.c:772
    

    经过排查错误发现是:Node.js版本太旧默认使用TLS1.1协议请求,解决这个问题有两种方法:

    1.手动指定成TLS1.2协议,secureProtocol参数设置成TLSv1_2_method

    var https = require('https');
    
    var options = {
      hostname: 'www.yourwebiste.com',
      port: 443,
      method: 'GET',
      path: '/validate',
      secureProtocol: 'TLSv1_2_method',
    };
    
    var req = https.request(options, function (res) {
      res.on('data', function (d) {
        process.stdout.write(d);
      });
    });
    req.end();
    
    req.on('error', function (e) {
      console.error(e);
    });
    

    2.升级Node.js到最新的稳定版本

  • 相关阅读:
    mysql_单表查询
    mysql_建表
    MySQL基础
    JS_左边栏菜单
    Vue框架之组件系统
    Vue常用语法及命令
    Django的缓存,序列化,ORM操作的性能
    Django中的form表单
    Django中的auth模块
    AJAX请求提交数据
  • 原文地址:https://www.cnblogs.com/reggieqiao/p/13254788.html
Copyright © 2011-2022 走看看