mirror of https://github.com/flucont/btcloud.git
2 Commits
57cbf9315c
...
aba885f434
Author | SHA1 | Message | Date |
---|---|---|---|
flucout | aba885f434 |
update
|
3 months ago |
flucout | 5e1f19de53 |
支持生成自签SSL证书
|
3 months ago |
28 changed files with 785 additions and 514 deletions
-
29app/command/Clean.php
-
96app/common.php
-
33app/controller/Admin.php
-
54app/controller/Api.php
-
10app/lib/BtPlugins.php
-
1app/lib/ThirdPlugins.php
-
2app/middleware/LoadConfig.php
-
31app/script/cacert.sh
-
2app/view/admin/deplist.html
-
17app/view/admin/layout.html
-
6app/view/admin/list.html
-
6app/view/admin/log.html
-
12app/view/admin/login.html
-
13app/view/admin/plugins.html
-
6app/view/admin/pluginswin.html
-
6app/view/admin/record.html
-
2app/view/admin/set.html
-
86app/view/admin/ssl.html
-
6app/view/index/download.html
-
2app/view/install/index.html
-
12install.sql
-
7route/app.php
@ -0,0 +1,31 @@ |
|||
#!/bin/bash |
|||
|
|||
OPENSSL_CHECK=$(which openssl) |
|||
if [ "$?" != "0" ]; then |
|||
echo "未安装OpenSSL" |
|||
exit 1 |
|||
fi |
|||
|
|||
if [ ! -f ca.key ] && [ ! -f ca.crt ]; then |
|||
openssl genrsa -out ca.key 2048 |
|||
openssl req -new -x509 -utf8 -days 3650 -extensions v3_ca -subj "/C=CN/O=宝塔面板/CN=宝塔面板" -key ca.key -out ca.crt |
|||
fi |
|||
|
|||
openssl genrsa -out server.key 2048 |
|||
openssl req -new -nodes -key server.key -subj "/C=CN/O=BTPanel/CN=BTPanel" -out server.csr |
|||
openssl x509 -req -in server.csr -CA ca.crt -CAkey ca.key -CAcreateserial -out server.crt -days 3650 -extensions req_ext |
|||
|
|||
cat ca.crt >> server.crt |
|||
|
|||
openssl pkcs12 -export -out baota_root.pfx -inkey server.key -in server.crt -password pass: |
|||
if [ "$?" != "0" ]; then |
|||
echo "生成CA根证书失败" |
|||
exit 1 |
|||
fi |
|||
|
|||
mkdir -p ../../public/ssl |
|||
\cp baota_root.pfx ../../public/ssl/baota_root.pfx |
|||
\cp ca.crt ../../public/ssl/baota_root.crt |
|||
rm -f server.crt server.key server.csr |
|||
|
|||
echo "生成CA根证书成功" |
@ -0,0 +1,86 @@ |
|||
{extend name="admin/layout" /} |
|||
{block name="title"}自签名SSL证书生成{/block} |
|||
{block name="main"} |
|||
<style> |
|||
.control-label[is-required]:before { |
|||
content: "*"; |
|||
color: #f56c6c; |
|||
margin-right: 4px; |
|||
} |
|||
</style> |
|||
<div class="container" style="padding-top:70px;"> |
|||
<div class="col-sm-12 col-md-10 col-lg-8 center-block" style="float: none;"> |
|||
<div class="panel panel-primary"> |
|||
<div class="panel-heading"><h3 class="panel-title">自签名SSL证书生成</h3></div> |
|||
<div class="panel-body"> |
|||
{if $isca} |
|||
<div class="alert alert-warning" style="word-break:break-all;">下载CA证书并导入,可解决浏览器不安全提醒。<br/>Windows:<a href="/ssl/baota_root.pfx">baota_root.pfx</a>(密码为空),Mac/Linux:<a href="/ssl/baota_root.crt">baota_root.crt</a></div> |
|||
<form onsubmit="return makeSSL(this)" method="post" class="form" role="form"> |
|||
<div class="form-group"> |
|||
<label is-required="true" class="control-label">域名列表:</label> |
|||
<textarea class="form-control" name="domain_list" rows="6" placeholder="每行一个域名/IP,支持通配符" required></textarea> |
|||
</div> |
|||
<div class="form-group"> |
|||
<label class="control-label">通用名称:</label> |
|||
<input type="text" name="common_name" value="" placeholder="留空则为域名列表第一个域名" class="form-control"/> |
|||
</div> |
|||
<div class="form-group"> |
|||
<label is-required="true" class="control-label">有效天数:</label> |
|||
<input type="number" name="validity" value="3650" class="form-control" required/> |
|||
</div> |
|||
<div class="form-group text-center"> |
|||
<input type="submit" name="submit" value="生成自签名证书" class="btn btn-success btn-block"/> |
|||
</div> |
|||
<div class="form-group row" id="result" style="display:none;"> |
|||
<div class="col-md-6"> |
|||
<label class="control-label">SSL证书:</label> |
|||
<textarea class="form-control" name="ssl_cert" rows="5" onclick="copy(this)" title="点击复制"></textarea> |
|||
</div> |
|||
<div class="col-md-6"> |
|||
<label class="control-label">SSL证书私钥:</label> |
|||
<textarea class="form-control" name="ssl_key" rows="5" onclick="copy(this)" title="点击复制"></textarea> |
|||
</div> |
|||
</div> |
|||
</form> |
|||
{else} |
|||
<div class="alert alert-danger" role="alert">你还没有生成CA证书,无法生成SSL证书!</div> |
|||
<div class="alert alert-info" style="word-break:break-all;">执行以下命令,生成自签名CA证书。然后,可通过接口或当前页面生成SSL证书,用于面板访问。</div> |
|||
<div class="list-group-item" style="word-break:break-all;">cd {:app()->getRootPath()}app/script && chmod +x cacert.sh && ./cacert.sh</div><br/> |
|||
{/if} |
|||
</div> |
|||
</div> |
|||
<script src="{$cdnpublic}layer/3.5.1/layer.js"></script> |
|||
<script> |
|||
function makeSSL(obj){ |
|||
var ii = layer.load(2, {shade:[0.1,'#fff']}); |
|||
$.ajax({ |
|||
type : 'POST', |
|||
url : '/admin/ssl', |
|||
data : $(obj).serialize(), |
|||
dataType : 'json', |
|||
success : function(data) { |
|||
layer.close(ii); |
|||
if(data.code == 0){ |
|||
$("textarea[name='ssl_cert']").val(data.cert); |
|||
$("textarea[name='ssl_key']").val(data.key); |
|||
$("#result").show(); |
|||
layer.msg('SSL证书生成成功', {icon:1, time:800}); |
|||
}else{ |
|||
layer.alert(data.msg, {icon: 2}) |
|||
} |
|||
}, |
|||
error:function(data){ |
|||
layer.close(ii); |
|||
layer.msg('服务器错误'); |
|||
} |
|||
}); |
|||
return false; |
|||
} |
|||
function copy(obj){ |
|||
if($(obj).val() == '') return; |
|||
$(obj).select(); |
|||
document.execCommand("Copy"); |
|||
layer.msg('复制成功', {icon:1, time:500}); |
|||
} |
|||
</script> |
|||
{/block} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue