首页 > 其他分享 >SSL证书配置

SSL证书配置

时间:2023-05-10 22:13:01浏览次数:34  
标签:配置 const 证书 res app express SSL bonc

1.1 tomcat配置SSL证书

tomcat配置
# 上传证书
cp ../bonc.com.cn.jks ./conf/

# 修改配置
server.xml
<Connector port="443" protocol="HTTP/1.1" SSLEnabled="true"
              maxThreads="150" scheme="https" secure="true"
              keystoreFile="conf/domains.jks"
              keystorePass="80ISkH7c"   //证书密钥 ,密码文本那个
              clientAuth="false" sslProtocol="TLS" />
              
 <Connector port="8088" protocol="HTTP/1.1" SSLEnabled="true" maxThreads="150" scheme="https" secure="true" keystoreFile="/data01/bonc_zj/bonc_web/tomcat/ssl/bonc.com.cn.jks" keystorePass="bonc" clientAuth="false" sslProtocol="TLS" connectionTimeout="20000" maxHttpHeaderSize="81920" relaxedQueryChars="&lt;&gt;[\]{|}" URIEncoding="utf-8" />

# 修改配置
web.xml
<login-config>  
    <!-- Authorization setting for SSL -->  
    <auth-method>CLIENT-CERT</auth-method>  
    <realm-name>Client Cert Users-only Area</realm-name>  
</login-config>  
<security-constraint>  
    <!-- Authorization setting for SSL -->  
    <web-resource-collection >  
        <web-resource-name >SSL</web-resource-name>  
        <url-pattern>/*</url-pattern>  
    </web-resource-collection>  
    <user-data-constraint>  
        <transport-guarantee>CONFIDENTIAL</transport-guarantee>  
    </user-data-constraint>  
</security-constraint>


1.2 node.js 配置SSL证书

node.js 配置SSL证书
101.71.102.255
/home/bonc_zj/java_web/wisdom-study/wisdom-study
# 上传SSL证书
./ssl/bonc.com.cn.key
./ssl/bonc.com.cn.pem

代码修改

# ##########################################  代码  ####################################
/** 用于开发环境的服务启动 **/
const path = require("path"); // 获取绝对路径有用
const express = require("express"); // express服务器端框架
// const http = require("http");
const https = require("https");

const fs = require("fs");

const httpsOption = {
  key : fs.readFileSync(__dirname + "/ssl/bonc.com.cn.key"),
  cert: fs.readFileSync(__dirname + "/ssl/bonc.com.cn.pem")
}

const compression = require("compression");
const app = express(); // 实例化express服务
// const PORT = 8088; // 服务启动端口号
app.use(compression());

// http.createServer(app).listen(80);


/** express 跨域中间件 **/
const allowCrossDomain = function(req, res, next) {
  res.header("Access-Control-Allow-Origin", "*"); //自定义中间件,设置跨域需要的响应头。
  res.header("Access-Control-Allow-Headers", "Content-Type");
  res.header("Access-Control-Allow-Methods", "PUT,POST,GET,DELETE,OPTIONS");
  res.header("Access-Control-Allow-Credentials", "true");
  next();
};
app.use(allowCrossDomain); //运用跨域的中间件
/** express 跨域中间件 **/

// 如果是生产环境,则运行build文件夹中的代码
app.use(express.static("dist"));
app.get("*", function(req, res) {
  res.sendFile(path.join(__dirname, "dist",  "index.html"));
});

/** express 404 错误处理 **/
app.use(function(req, res, next) {
  var err = null;
  try {
    decodeURIComponent(req.path);
  } catch (e) {
    err = e;
  }
  if (err) {
    return res.redirect(["http://", req.get("Host"), "/404"].join(""));
  }
  next();
});

/** 启动服务 **/
// app.listen(PORT, () => {
//   console.log("本地服务启动地址: http://localhost:%s", PORT);
// });
https.createServer(httpsOption, app).listen(8088);

1.3 nginx配置

nginx配置

标签:配置,const,证书,res,app,express,SSL,bonc
From: https://www.cnblogs.com/route/p/17389488.html

相关文章

  • 7月22日自助装机配置专家点评
    配件数量单价品牌型号CPU11105AMDPhenomX49550散热系统00 主板1699捷波悍马HA03内存2255金士顿DDR28002G硬盘1585西部数据500GSATAII16M(WD5001ABYS)显卡1899蓝宝石HD3870蓝曜天刃512M声卡00 光驱1140三星TS-H352D刻录机00 键鼠套装1130罗技光电高手800键鼠套装......
  • nginx:配置nginx访问php(nginx/1.24.0)
    一,配置nginx虚拟主机1,查看php-fpm使用的端口:[root@img~]#ss-lntp|grepphp如图:可以看到端口是90002,配置虚拟主机:如下:[[email protected]]#vifile.conf内容如下:server{    listen       80;    server_name  file.liuhongdi.com; ......
  • JFrog Artifactory 系列3 --- 仓库与配置
    一、概念1.承上启下JFrogArtifactory系列1---安装与配置JFrogArtifactory系列2---Https2.仓库种类(1)按逻辑结构划分从逻辑上讲,最常用的制品库类型有以下三种:a.LocalRepositories(本地仓库):用于搭建私有仓库,存储组织内部制品;b.RemoteRepositories(远程仓库......
  • Linux系统下Samba服务器的配置
    第1步:将目录/home/media设置为允许所有用户访问,但仅允许用户mary具有修改该目录的权限。其配置步骤简述如下。第2步:将目录/var/samba/student设置为只允许student组的成员访问,student组中有stu01、stu02·····stu05,共5个成员。配置步骤简述如下。第3步:用testparm命令测试......
  • Linux系统下NFS服务器的配置
    第1步:NFS规划。1)将本地文件系统的/home/mp3目录共享,mary客户机对该目录具有读写限权,其他所有用户对该目录具有只读限权。 2)将本地文件系统的/home/vedio目录共享,192.168.21.100与192.168.21.200两个客户机对该目录具有读写限权,而192.168.21.0、24网段内的其他客户机对该目录......
  • Vue2项目中,在编译打包后通过读取配置文件,任意修改接口地址
    可以按照以下步骤进行操作: 1.在项目根目录下创建一个名为`config`的文件夹,并在该文件夹下创建一个名为`index.js`的文件,用来存放配置文件,如: ```javascriptmodule.exports={  apiRoot:'http://api.example.com'}``` 这里定义了一个`apiRoot`属性,用来存放接口地......
  • 博客证书过期了
    今天想用Draw画点东西的时候,发现ssl不可信了。一看是证书过期,于是重新申请了一个替换。但替换后偶然注意到证书可信度检查为低,证书评级也为B,这里记录一下处理方式:在nginx配置中加以下配置即可: #PCIDSS不合规ssl_protocolsTLSv1.2TLSv1.3; #没......
  • FreeSWITCH部署与功能配置
    一.FreeSWITCH服务部署1.wgethttp://www.freeswitch.org.cn/Makefile&&makeinstall2.cdfreeswitch3.运行./bootstrap.sh(作用:初始化环境)4.执行./configure(主要的作用是对即将安装的软件进行配置,检查当前的环境是否满足要安装软件的依赖关系,但并不是所有的tar包都是源代......
  • Linux系统下NFS服务器的配置
    第1步:NFS规划。1)将本地文件系统的/home/mp3目录共享,mary客户机对该目录具有读写限权,其他所有用户对该目录具有只读限权。 2)将本地文件系统的/home/vedio目录共享,192.168.21.100与192.168.21.200两个客户机对该目录具有读写限权,而192.168.21.0、24网段内的其他客户机对该目录......
  • Linux系统下Samba服务器的配置
    第1步:将目录/home/media设置为允许所有用户访问,但仅允许用户mary具有修改该目录的权限。其配置步骤简述如下。第2步:将目录/var/samba/student设置为只允许student组的成员访问,student组中有stu01、stu02·····stu05,共5个成员。配置步骤简述如下。第3步:用testparm命令测试......