导出证书

This commit is contained in:
Arno 2019-04-08 15:21:31 +08:00
parent 3ef6b4191a
commit 2474f44188
4 changed files with 96 additions and 1 deletions

View File

@ -3,6 +3,8 @@ package cn.keepbx.jpom.controller.system.ssl;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.lang.Validator;
import cn.hutool.core.util.StrUtil;
import cn.hutool.core.util.ZipUtil;
import cn.hutool.extra.servlet.ServletUtil;
import cn.jiangzeyin.common.DefaultSystemLog;
import cn.jiangzeyin.common.JsonMessage;
import cn.jiangzeyin.controller.multipart.MultipartFileBuilder;
@ -162,4 +164,17 @@ public class CertificateController extends BaseController {
}
return JsonMessage.getString(200, "删除成功");
}
/**
* 导出证书
*/
@RequestMapping(value = "/export", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@ResponseBody
public void export(String path) {
String parent = FileUtil.file(path).getParent();
File zip = ZipUtil.zip(parent);
ServletUtil.write(getResponse(), zip);
FileUtil.del(zip);
}
}

View File

@ -35,6 +35,10 @@
.input_msg {
margin-top: 18px;
}
.certText {
padding: 10px;
}
</style>
</head>
@ -103,6 +107,9 @@
</form>
</div>
<div id="cert_template" class="div-certificate">
</div>
</body>
<script type="text/html" id="bar_cert">
<a href="javascript:;" class="layui-btn layui-btn-sm layui-btn-warm" lay-event="update">编辑</a>
@ -117,6 +124,48 @@
<script type="text/html" id="tem_expirationTime">
{{ formateTime(d.expirationTime) }}
</script>
<script type="text/html" id="tem_cert">
<div class="certText">
<table>
<tr>
<td>ssl</td>
<td> on;</td>
</tr>
<tr>
<td>listen</td>
<td> 443 ssl;</td>
</tr>
<tr>
<td>server_name</td>
<td> {{ d.domain }};</td>
</tr>
<tr>
<td>ssl_certificate</td>
<td> {{ d.cert }};</td>
</tr>
<tr>
<td>ssl_certificate_key</td>
<td> {{ d.key }};</td>
</tr>
<tr>
<td>ssl_session_cache</td>
<td> shared:SSL:1m;</td>
</tr>
<tr>
<td>ssl_session_timeout</td>
<td> 5m;</td>
</tr>
<tr>
<td>ssl_ciphers</td>
<td> HIGH:!aNULL:!MD5;</td>
</tr>
<tr>
<td>ssl_prefer_server_ciphers &nbsp;</td>
<td> on;</td>
</tr>
</table>
</div>
</script>
<script type="text/javascript">
@ -172,9 +221,39 @@
} else if ('delete' === event) {
// 删除
deleteCert(data);
} else if ('export' === event) {
window.location.href = "./export?path=" + data.cert;
} else if ('templte' === event) {
openTemplate(data);
}
});
//打开模板
function openTemplate(data) {
// $("#template").removeClass("div-certificate");
layer.open({
type: 1,
title: '模板',
content: $('#cert_template'),
area: ['40%', '40%'],
// btnAlign: 'c',
// btn: ['提交'],
yes: function (index, layero) {
}
});
var page = tem_cert.innerHTML;
var view = document.getElementById('cert_template');
layui.use(['laytpl'], function () {
var laytpl = layui.laytpl;
laytpl(page).render(data, function (html) {
view.innerHTML = html;
});
});
}
// 修改证书
function updateCert(data) {
document.getElementById('form_certificate').reset();

View File

@ -74,7 +74,6 @@
<script type="text/javascript">
var laytpl;
var index = 0;
function loadSuccess() {

View File

@ -270,6 +270,8 @@
suffix = " GB";
}
value = value.toFixed(2);
} else {
value = value.toFixed(4);
}
return params.seriesName + '<br/>' + params.name + " : " + value + suffix + "(" + params.percent + "%)";
}