8a538feeec83b2d4e4ac96a6efbd8ec3d0352e61
[cacert.git] / pages / help / 9.php
1 <? /*
2 LibreSSL - CAcert web application
3 Copyright (C) 2004-2008 CAcert Inc.
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; version 2 of the License.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */ ?>
18 <?
19 function dotab($num)
20 {
21 $string="";
22 for($i = 0; $i < $num; $i++)
23 {
24 for($j = 0; $j < 8; $j++)
25 $string .= "&nbsp;";
26 }
27 return($string);
28 }
29 ?>
30 <h3><?=_("How can I do a single sign on similar to CAcert using client certificates?")?></h3>
31
32 <p><?=_("Firstly you need mod-ssl and apache setup (this is beyond the scope of this FAQ item and you will need to search on google etc for LAMP setup information). I recommend mod-ssl over apache-ssl because it means you need less resources to achieve the same result.")?></p>
33
34 <p><?=_("Once you have everything setup and working you will need to add lines similar to below to your apache.conf")?></p>
35
36 <p style="border:dotted 1px #900;padding:0.3em;background-color:#ffe;"><br>
37 &lt;VirtualHost 127.0.0.1:443&gt;<br>
38 SSLEngine on<br>
39 SSLVerifyClient require<br>
40 SSLVerifyDepth 2<br>
41 SSLCACertificateFile /etc/ssl/cacert.crt<br>
42 SSLCertificateFile /etc/ssl/certs/cacert.crt<br>
43 SSLCertificateKeyFile /etc/ssl/private/cacert.pem<br>
44 SSLOptions +StdEnvVars<br>
45 <br>
46 ServerName secure.cacert.org<br>
47 DocumentRoot /www<br>
48 &lt;/VirtualHost&gt;<br><br>
49 </p>
50
51 <p><?=_("Please note, you will need to alter the paths, hostname and IP of the above example, which is just that an example! The SSLCACertificateFile directive is supposed to point to a file with the root certificate you wish to verify your client certificates against, for the CAcert website we obviously only accept certificates issued by our own website and use our root certificate to initially verify this.")?></p>
52
53 <p><?=_("Once you have everything working and you've tested sending a client certificate to your site and you're happy all is well you can start adding code to PHP (or any other language you like that can pull server environment information). At present I only have PHP code available and the example is in PHP")?></p>
54
55 <p style="border:dotted 1px #900;padding:0.3em;background-color:#ffe;"><br>
56 <?=dotab(1)?>if($_SERVER['HTTP_HOST'] == "secure.cacert.org")<br>
57 <?=dotab(1)?>{<br>
58 <?=dotab(2)?>$query = "select * from `users` where `email`='$_SERVER[SSL_CLIENT_S_DN_Email]'";<br>
59 <?=dotab(2)?>$res = mysql_query($query);<br>
60 <?=dotab(2)?>if(mysql_num_rows($res) > 0)<br>
61 <?=dotab(2)?>{<br>
62 <?=dotab(3)?>$_SESSION['profile']['loggedin'] = 1;<br>
63 <?=dotab(3)?>header("location: https://secure.cacert.org/account.php");<br>
64 <?=dotab(3)?>exit;<br>
65 <?=dotab(2)?>}<br>
66 <?=dotab(1)?>}<br><br>
67 </p>