149  
查询码:00000680
O2OA启用HTTPS(SSL)
作者: 王兰 于 2021年12月10日 发布在分类 / 人防组 / 人防后端 下,并于 2021年12月10日 编辑

O2OA支持以SSL方式连接WEB服务器,应用服务器以及中心服务器,以获得更高的网络安全性。


一、WEB和应用服务器配置

1、文件位置:o2server/config/node_127.0.0.1.json, 如果目录里没有该文件,可以从o2server/configSample目录里COPY一个到config目录下。

直接修改o2server/configSample下的node_127.0.0.1.json配置将不会生效。

如下图所示:

复制配置文件

2、修改node_127.0.0.1.json内容:

{
  "enable": true,
  "isPrimaryCenter": true,
  "application": {
    "enable": true,
    "port": 20020.0,
    "sslEnable": true,         #启用SSL
    "proxyHost": "",
    "proxyPort": 20020.0,
    "redeploy": true,
    "scanInterval": 0.0,
    "includes": [],
    "excludes": [],
    "weights": []
  },
  "web": {
    "enable": true,
    "sslEnable": true,         #启用SSL
    "port": 443,               #修改端口为443
    "weight": 100.0
  },
  "data": {
    "enable": true,
    "tcpPort": 20050.0,
    "webPort": 20051.0,
    "includes": [],
    "excludes": [],
    "jmxEnable": false,
    "cacheSize": 512.0
  },
  "storage": {
    "enable": true,
    "port": 20040.0,
    "sslEnable": false,
    "name": "251",
    "accounts": []
  },
  "logLevel": "warn",
  "dumpData": {
    "cron": "",
    "size": 14.0,
    "###cron": "定时任务cron表达式###",
    "###size": "最大保留分数,超过将自动删除最久的数据.###"
  },
  "dumpStorage": {
    "cron": "",
    "size": 14.0,
    "###cron": "定时任务cron表达式###",
    "###size": "最大保留分数,超过将自动删除最久的数据.###"
  },
  "restoreData": {
    "cron": "",
    "date": "",
    "###cron": "定时任务cron表达式###",
    "###date": "导入数据时间戳,需要在local/dump下有此时间戳的文件.###"
  },
  "restoreStorage": {
    "cron": "",
    "date": "",
    "###cron": "定时任务cron表达式###",
    "###date": "导入数据时间戳,需要在local/dump下有此时间戳的文件.###"
  },
 ......
}

将配置文件中的web和application对象中的sslEnable设置为true, web服务器的端口设定为443。


二、中心服务器配置

1、文件位置:o2server/config/centerServer.json, 如果目录里没有该文件,可以从o2server/configSample目录里COPY一个到config目录下。

如下图所示:

复制centerServer.json

2、修改centerServer.json内容:

{
  "sslEnable": true,       #启动SSL
  "redeploy": true,
  "port": 20030.0,
  "httpProtocol": "",
  "proxyHost": "",
  "proxyPort": 20030.0,
  "scanInterval": 0.0,
  "###enable": "是否启用###",
  "###sslEnable": "是否启用ssl传输加密,如果启用将使用config/keystore文件作为密钥文件.使用config/token.json文件中的sslKeyStorePassword字段为密钥密码,sslKeyManagerPassword为管理密码.###",
  "###redeploy": "每次启动是否重新部署所有应用.###",
  "###port": "端口,center服务器端口,默认20030###",
  "###httpProtocol": "对外http访问协议,http/https###",
  "###proxyHost": "代理主机,当服务器是通过apache/eginx等代理服务器映射到公网或者通过路由器做端口映射,在这样的情况下需要设置此地址以标明公网访问地址.###",
  "###proxyPort": "代理端口,当服务器是通过apache/eginx等代理服务器映射到公网或者通过路由器做端口映射,在这样的情况下需要设置此地址以标明公网访问端口.###",
  "###scanInterval": "重新扫描war包时间间隔(秒)###",
  "###config": "其他参数###"
}

将配置文件中的sslEnable设置为true。


三、自签名SSL证书验证HTTPS功能

使用openssl创建自签名证书

1.创建根证书私钥以及请求文件:

openssl genrsa -out rootkey.key 1024 openssl req -new -out rootreq.csr -key rootkey.key

2.自签名根证书:

openssl x509 -req -in rootreq.csr -out rootcert.cer -signkey rootkey.key -CAcreateserial -days 3650

3.生成key:

openssl genrsa -out clientkey.key 1024

4.生成请求文件:

openssl req -new -out clientreq.csr -key clientkey.key

5.生成证书:

openssl x509 -req -in clientreq.csr -out clientcert.cer -signkey clientkey.key -CA rootcert.cer -CAkey rootkey.key -CAcreateserial -days 3650

6.生成p12证书:

openssl pkcs12 -export -clcerts -in clientcert.cer -inkey clientkey.key -out keystore

这里我们得到了进行ssl加密所需要的证书文件keystore


四、配置服务器使用ssl

1.将最终生成的keystore文件拷贝至o2server/config目录

2.编辑o2server/config/token.json文件中的

token.json 配置

sslKeyStorePassword: "您设置的密码"

"sslKeyManagerPassword": "您设置的密码"

3.在node配置文件中的application,center,web设置sslEnable:true

4.重启服务器完成配置,使用https进行访问.



 推荐知识

 历史版本

修改日期 修改人 备注
2021-12-10 16:26:24[当前版本] 王兰 创建版本

 附件

附件类型

GIFGIF

知识分享平台 -V 4.8.7 -wcp