You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

85 lines
3.6 KiB

  1. {extend name="admin/layout" /}
  2. {block name="title"}自签名SSL证书生成{/block}
  3. {block name="main"}
  4. <style>
  5. .control-label[is-required]:before {
  6. content: "*";
  7. color: #f56c6c;
  8. margin-right: 4px;
  9. }
  10. </style>
  11. <div class="container" style="padding-top:70px;">
  12. <div class="col-sm-12 col-md-10 col-lg-8 center-block" style="float: none;">
  13. <div class="panel panel-primary">
  14. <div class="panel-heading"><h3 class="panel-title">自签名SSL证书生成</h3></div>
  15. <div class="panel-body">
  16. {if $isca}
  17. <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>
  18. <form onsubmit="return makeSSL(this)" method="post" class="form" role="form">
  19. <div class="form-group">
  20. <label is-required="true" class="control-label">域名列表:</label>
  21. <textarea class="form-control" name="domain_list" rows="6" placeholder="每行一个域名/IP,支持通配符" required></textarea>
  22. </div>
  23. <div class="form-group">
  24. <label class="control-label">通用名称:</label>
  25. <input type="text" name="common_name" value="" placeholder="留空则为域名列表第一个域名" class="form-control"/>
  26. </div>
  27. <div class="form-group">
  28. <label is-required="true" class="control-label">有效天数:</label>
  29. <input type="number" name="validity" value="3650" class="form-control" required/>
  30. </div>
  31. <div class="form-group text-center">
  32. <input type="submit" name="submit" value="生成自签名证书" class="btn btn-success btn-block"/>
  33. </div>
  34. <div class="form-group row" id="result" style="display:none;">
  35. <div class="col-md-6">
  36. <label class="control-label">SSL证书:</label>
  37. <textarea class="form-control" name="ssl_cert" rows="5" onclick="copy(this)" title="点击复制"></textarea>
  38. </div>
  39. <div class="col-md-6">
  40. <label class="control-label">SSL证书私钥:</label>
  41. <textarea class="form-control" name="ssl_key" rows="5" onclick="copy(this)" title="点击复制"></textarea>
  42. </div>
  43. </div>
  44. </form>
  45. {else}
  46. <div class="alert alert-danger" role="alert">你还没有生成CA证书,无法生成SSL证书!</div>
  47. <div class="alert alert-info" style="word-break:break-all;">执行以下命令,生成自签名CA证书。然后,可通过接口或当前页面生成SSL证书,用于面板访问。</div>
  48. <div class="list-group-item" style="word-break:break-all;">cd {:app()->getRootPath()}app/script && chmod +x cacert.sh && ./cacert.sh</div><br/>
  49. {/if}
  50. </div>
  51. </div>
  52. <script src="{$cdnpublic}layer/3.5.1/layer.js"></script>
  53. <script>
  54. function makeSSL(obj){
  55. var ii = layer.load(2, {shade:[0.1,'#fff']});
  56. $.ajax({
  57. type : 'POST',
  58. url : '/admin/ssl',
  59. data : $(obj).serialize(),
  60. dataType : 'json',
  61. success : function(data) {
  62. layer.close(ii);
  63. if(data.code == 0){
  64. $("textarea[name='ssl_cert']").val(data.cert);
  65. $("textarea[name='ssl_key']").val(data.key);
  66. $("#result").show();
  67. layer.msg('SSL证书生成成功', {icon:1, time:800});
  68. }else{
  69. layer.alert(data.msg, {icon: 2})
  70. }
  71. },
  72. error:function(data){
  73. layer.close(ii);
  74. layer.msg('服务器错误');
  75. }
  76. });
  77. return false;
  78. }
  79. function copy(obj){
  80. if($(obj).val() == '') return;
  81. $(obj).select();
  82. document.execCommand("Copy");
  83. layer.msg('复制成功', {icon:1, time:500});
  84. }
  85. </script>
  86. {/block}