Alternc  latest
Alternc logiel libre pour l'hébergement
ssl_new.php
Go to the documentation of this file.
1 <?php
2 /*
3  ----------------------------------------------------------------------
4  AlternC - Web Hosting System
5  Copyright (C) 2002 by the AlternC Development Team.
6  http://alternc.org/
7  ----------------------------------------------------------------------
8  LICENSE
9 
10  This program is free software; you can redistribute it and/or
11  modify it under the terms of the GNU General Public License (GPL)
12  as published by the Free Software Foundation; either version 2
13  of the License, or (at your option) any later version.
14 
15  This program is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  GNU General Public License for more details.
19 
20  To read the license please visit http://www.gnu.org/copyleft/gpl.html
21  ----------------------------------------------------------------------
22  Original Author of file: Benjamin Sonntag
23  Purpose of file: Create / Import an SSL Certificate
24  ----------------------------------------------------------------------
25  */
26 require_once("../class/config.php");
27 include_once("head.php");
28 
29 if (!isset($is_include)) {
30  $fields = array(
31  "fqdnt" => array("request", "string", ""),
32  "key" => array("request", "string", ""),
33  "crt" => array("request", "string", ""),
34  "chain" => array("request", "string", ""),
35  );
37 }
38 
39 $advice = $ssl->get_new_advice();
40 ?>
41 
42 <h3><?php __("New SSL Certificate"); ?></h3>
43 
44 <?php
45 if (isset($error) && $error) {
46  echo "<p class=\"alert alert-danger\">$error</p>";
47 }
48 ?>
49 <p>
50  <?php __("An SSL certificate is a file which must be obtained from a Certificate Authority, and allow you to enable HTTPS encryption on a domain name."); ?>
51 </p>
52 <p>
53  <?php __("To obtain one, you need to generate a <i>Certificate Request</i> (CSR) and a <i>RSA Key</i> (KEY) here, then give the CSR to the Certificate Authority, which will give you a certificate (CRT) and also often a chained certificate (CHAIN)."); ?>
54 </p>
55 <p>
56  <?php __("If you already know what it is and already have all those files (CRT/KEY/CHAIN) You can import them here too."); ?>
57 </p>
58 
59 
60 <div id="content">
61  <div id="tabsssl">
62 
63  <ul>
64  <li class="add"><a href="#tabsssl-create"><?php __("Create a CSR/KEY"); ?></a></li>
65  <li class="settings"><a href="#tabsssl-import"><?php __("Import existing files"); ?></a></li>
66  </ul>
67 
68  <div id="tabsssl-create">
69  <h3><?php __("Create a CSR/KEY for a given domain name"); ?></h3>
70 
71  <p><?php __("Use this form to generate a <i>Certificate Request file</i> (CSR) and a <i>RSA Key file</i> (KEY) for a given domain name"); ?></p>
72 
73  <script type="text/javascript">
74  function switchmanual() {
75  if ($("#fqdn").val() == -1) {
76  $("#fqdn").hide();
77  $("#fqdnt").show();
78  $("#relist").show();
79  $("#fqdn").val("");
80  $("#fqdnt").focus();
81  }
82  }
83 
84  function switchlist() {
85  $("#fqdn").show();
86  $("#fqdnt").hide();
87  $("#relist").hide();
88  $("#fqdnt").val("");
89  $("#fqdn").val("");
90  $("#fqdn").focus();
91  }
92 
93  </script>
94 
95  <form method="post" action="ssl_donew.php" name="main" id="main">
96 <?php csrf_get(); ?>
97  <table border="1" cellspacing="0" cellpadding="4" class="tedit">
98  <tr><td colspan="2">
99  <?php __("Please choose the domain name for which you want a SSL Certificate, or enter it manually"); ?>
100  </td></tr>
101  <tr>
102  <th><label for="fqdn"><?php __("Fully Qualified Domain Name"); ?></label></th>
103  <td>
104  <select name="fqdn" id="fqdn" onchange="switchmanual()"<?php if ($fqdnt != "") echo " style=\"display: none\""; ?>>
105  <option value=""><?php __("--- Choose here ---"); ?></option>
106  <?php
107  foreach ($advice as $a) {
108  echo "<option>" . $a . "</option>";
109  }
110  ?>
111  <option value="-1" style="font-style: italic; padding-left: 80px"> <?php __("... or click here to enter it manually"); ?></option>
112  </select>
113  <input<?php if ($fqdnt == "") echo " style=\"display: none\""; ?> type="text" class="int" name="fqdnt" id="fqdnt" value="" size="40" maxlength="64" /><input <?php if ($fqdnt == "") echo " style=\"display: none\""; ?> type="button" id="relist" name="relist" value=" list v " onclick="switchlist()" />
114  </td>
115  </tr>
116  </table>
117  <p>
118  <input type="submit" class="inb ok" name="submit" value="<?php __("Save"); ?>"/> &nbsp;
119  <input type="button" class="inb cancel" name="cancel" value="<?php __("Cancel"); ?>" onclick="document.location = 'ssl_list.php'"/>
120  </p>
121  </form>
122 
123  <div style="padding-left: 40px; margin-top: 20px; background: url(/images/warning.png) 5px 5px no-repeat">
124  <p><?php __("Please note that a SSL Certificate is only valid for one fully qualified domain name. As a result, a certificate for <code>www.example.com</code> is NOT valid for <code>intranet.example.com</code> or <code>intranet.www.example.com</code> !"); ?> <br /><?php __("<i>(If you want to get a valid certificate for all the subdomains of a domain, use a wildcard notation (eg: *.example.com). Please note that a wildcard certificate is usually more expensive than normal one.)</i>"); ?></p>
125  </div>
126 
127  </div> <!-- create -->
128 
129 
130  <div id="tabsssl-import">
131  <h3><?php __("Import existing Private Key, Certificate and Chain files"); ?></h3>
132 
133  <p><?php __("If you already have a RSA Private Key file, a Certificate for this key and (maybe) a Chained certificate, please paste their content here."); ?></p>
134  <p><?php __("We will verify the content of those files and add them in your certificate repository"); ?></p>
135 
136  <form method="post" action="ssl_doimport.php" name="main" id="main">
137 <?php csrf_get(); ?>
138  <table border="1" cellspacing="0" cellpadding="4" class="tedit">
139  <tr>
140  <th><label for="key"><?php __("RSA Private Key"); ?></label></th>
141  <td><textarea class="int" name="key" id="key" style="width: 420px; height: 120px;"><?php echo htmlentities($key); ?></textarea></td>
142  </tr>
143  <tr>
144  <th><label for="crt"><?php __("SSL Certificate"); ?></label></th>
145  <td><textarea class="int" name="crt" id="crt" style="width: 420px; height: 120px;"><?php echo htmlentities($crt); ?></textarea></td>
146  </tr>
147  <tr>
148  <th><label for="chain"><?php __("Chained Certificate<br />(not mandatory)"); ?></label></th>
149  <td><textarea class="int" name="chain" id="chain" style="width: 420px; height: 120px;"><?php echo htmlentities($chain); ?></textarea></td>
150  </tr>
151  </table>
152  <p>
153  <input type="submit" class="inb ok" name="submit" value="<?php __("Save"); ?>"/> &nbsp;
154  <input type="button" class="inb cancel" name="cancel" value="<?php __("Cancel"); ?>" onclick="document.location = 'ssl_list.php'"/>
155  </p>
156  </form>
157  </div> <!-- create -->
158 
159  </div>
160 </div>
161 <script type="text/javascript">
162  $(function() {
163  $("#tabsssl").tabs(<?php if ($crt != "" and $key != "") echo "{ active: 1 }"; ?>);
164  });
165 </script>
166 <?php
167 include_once("foot.php");
168 ?>
$fields
Definition: aws_add.php:27
__($str)
Definition: functions.php:404
getFields($fields, $requestOnly=false)
Get the Fields of the posted form from $_REQUEST or POST or GET and check their type.
Definition: functions.php:688
csrf_get($return=false)
Give a new CSRF uniq token for a form the session must be up since the CSRF is linked to the session ...
Definition: functions.php:1159
$error
Definition: ssl_delete.php:45
if($error) $is_include
Definition: ssl_donew.php:55
if(!isset($is_include)) $advice
Definition: ssl_new.php:39
if(empty($_POST['key'])||empty($_POST['val'])) $key
Definition: tempovars.php:14