当前位置: 首页 > article >正文

swagger stub https无法访问

有个app的以前别人写的假服务用http访问可以,但是用https去访问就不行

看官方说schema里面配置一个https就可以了但是对我那个server没有用:

官方参考链接:

API Host and Base Path

后来领导给我发了个这个:

Node.js Express で HTTPSを利用するパターン #Node.js - Qiita

说是需要生成一个证书什么的放在options里面

var options = {

key: fs.readFileSync('../localhost.key'),

cert: fs.readFileSync('../localhost.crt')

};

这里的证书需要生成参考下面的链接里面生成证书的命令,然后放到server的最外层同一级目录下

生成证书命令:

openssl req -x509 -out localhost.crt -keyout localhost.key \
  -newkey rsa:2048 -nodes -sha256 \
  -subj '/CN=localhost' -extensions EXT -config <( \
   printf "[dn]\nCN=localhost\n[req]\ndistinguished_name = dn\n[EXT]\nsubjectAltName=DNS:localhost\nkeyUsage=digitalSignature\nextendedKeyUsage=serverAuth")

参考链接:localhost 证书 - Let's Encrypt - 免费的SSL/TLS证书

然后在https里面加上这个参数重启服务就可以访问了

https = require("https");

https.createServer(options,app).listen(serverPort_https, function () {

console.log(

"Your server is listening on port %d (https://localhost:%d)",

serverPort_https,

serverPort_https

);

);

});


http://www.kler.cn/a/103997.html

相关文章:

  • React hooks介绍及使用
  • MySQL精髓:如何使用ALL一次找到最大值
  • mysql 命令行安装
  • 【人工智能Ⅰ】实验1:谓词表示法与产生式知识表示
  • vueDay04——v-if else show
  • python sqlalchemy(ORM)- 02 表关系
  • ftp远程连接传输的常见问题有哪些?如何一站式解决传输问题?
  • Redis的开发利用
  • Redis主从模式(二)---拓扑结构及复制过程
  • 【stm32】stm32MX定时器
  • 嵌入式中的MCU、ARM、DSP、FPGA
  • 20231024后端研发面经整理
  • ArcGIS笔记12_ArcGIS搜索工具没法用?ArcGIS运行很慢很卡?
  • Hadoop分布式安装
  • 【可视化Java GUI程序设计教程】第4章 布局设计
  • 【Java】泛型擦除机制
  • vue 中 mixin 和 mixins 区别
  • hbase和aerospike基础概念及所对应的python包API使用
  • 深度学习_4_实战_直线最优解
  • 6.6 Elasticsearch(六)京淘项目改造