14 KiB
Directory structure
root Directory
The root directory contains
- a
.gitignore
file with a list of excluded files - a
LICENSE
file the GPL license text - a
README
file with very rudimentary documentation stating the license and a list of system requirements
cgi-bin
Directory cgi-bin
The cgi-bin directory contains
PHP
siteseal.cgi
a PHP CGI script that generates some JavaScript code to invokesealgen.php <www-sealgen-php>
. The configuration on www.cacert.org does not seem to support this script https://www.cacert.org/cgi-bin/siteseal.cgi returns a 403 response.
commModule
Perl
bash
Directory CommModule
This directory contains the CommModule that is implemented in Perl:
client.pl
thesigner protocol <signer>
client, running on the webserver and talking to the server via a serial link.The style of the Perl code seems a bit inconsistent (mix of uppercase and lowercase function names, usage of brackets). The code uses database polling in a loop. It might be a better idea to use some kind of queueing (Redis, AMQP, ...) to not waste resources when there is nothing to do). Function parameters are not named which makes the code hard to read.
The script calls several system binaries that need to be present in compatible versions:
openssl
xdelta
The script uses several Perl standard library modules as well as the following third party modules:
Perl, thirdparty
The script references several openssl configuration files in the HandleCerts function that are not included in the code repository. There are some openssl configuration files with similar names in https://svn.cacert.org/CAcert/SystemAdministration/signer/
The database password is parsed from
includes/mysql.php <includes-mysql-php>
and relies on the exact code that is defined there. Database name, user and host are hardcoded in the DBI->connect call.The script implements the client side of the signer protocol which is specified in
signer
.The script performs the following operations:
- parse password from
includes/mysql.php
- read a list of CRL files and logs their SHA-1 hashes
- read
serial.conf
, create a Device::SerialPort instance $portObj, sets serial parameters and savesserial.conf
- run a main loop as long as a file
./client.pl-active
is present. The main loop performs the following tasks- handle pending OpenPGP key signing request via
HandleGPG()
- handle pending certificate signing requests:
- personal client certificates via
HandleCerts(0, 0)
- personal server certificates via
HandleCerts(0, 1)
- organization client certificates via
HandleCerts(1, 0)
- organization server certificates via
HandleCerts(1, 1)
- personal client certificates via
- handle pending certificate revocation requests
- personal client certificates via
RevokeCerts(0, 0)
- personal server certificates via
RevokeCerts(0, 1)
- organization client certificates via
RevokeCerts(1, 0)
- organization server certificates via
RevokeCerts(1, 1)
- personal client certificates via
- refresh
CRLs <CRL>
viaRefreshCRLs()
in every 100st iteration - send a
NUL request <signer-nul-request-format>
to keep the signer connection alive - sleep for 2.7 seconds
- handle pending OpenPGP key signing request via
There is potential for optimization in the main loop. The CRL update could be performed if a certificate has been revoked. The NUL request needs only to be sent if no other request has been sent.
The script uses a lot of temporary files instead of piping input and output to and from external commands.
describe more in-depth what each of the main loop steps does
commdaemon
a script to runclient.pl <commmodule-client-pl>
orserver.pl <commmodule-server-pl>
This bash script is automatically restarting the
{script}
given as the first parameter as long as a file{script}-active
exists. Informational messages and errors are logged to syslog vialogger
.The script is most probably used to recover from crashed scripts. This could be implemented via
supervisor
orsystemd
instead of a custom script.commmodule
a System V style init script for startup/shutdown of CommModuleOn test.cacert.org two slightly different versions are deployed in
/etc/init.d
the first version startsclient.pl <commmodule-client-pl>
in/home/cacert/www/CommModule/
and the second variant startsserver.pl <commmodule-server-pl>
in/home/signer/cacert-devel/CommModule/
.logclean.sh
maintenance script for logfiles generated by CommModuleThe
logclean.sh
script performs log rotation of signer logfiles.discuss replacement of this script with
logrotate
and a custom logrotate.conf for the signerserial.conf
serial port configuration fileThis file is read and written by both
client.pl <commmodule-client-pl>
andserver.pl <commmodule-server-pl>
therefore both cannot be run from the same directory without interfering with each other.add a serial.conf template and move the actual serial.conf into configuration management
server.pl
the real server, running on the signing serverThis script implements the signer (server) side of the
signer protocol <signer>
and performs the actual signing operations.The script contains a some code that is duplicated by
client.pl <commmodule-client-pl>
.Note
The
server.pl
used on test.cacert.org is different from the version in the cacert-devel repository. The git origin is recorded as git://git-cacert.it-sls.de/cacert-devel.git and there are some small uncommitted changes too.get the versions of server.pl on git.cacert.org, the real production signer and the cacert-devel repository synchronized
usbclient.pl
obsoleted USB version ofclient.pl <commmodule-client-pl>
aboveremove unused file (usbclient.pl)
includes
PHP
Directory includes
.cvsignore
includes the parameters for CVS, which files to ignore by versioning
.gitignore
includes the parameters for GIT, which files to ignore by versioning
about_menu.php
is a part (<div>) of a PHP-Page, containing most of the CAcert-related links.
account_stuff.php
account.php
general_stuff.php
general.php
keygen.php
loggedin.php
mysql.php.sample
is a template for the database connection handling code that is meant to be copied tomysql.php
.The template defines the MySQL connection as a session variable mconn and tries to connect to that database. It also defines the session variables normalhostname, securehostname and tverify.
The template defines a function :php
sendmail
for sending mails.Configuration and actual code are mixed. It would be better to have a separate file that just includes configuration.
This file is parsed by
CommModule/client.pl <commmodule-client-pl>
format changes might break the CommModule code.
notary.inc.php
shutdown.php
sponsorinfo.php
tverify_stuff.php
includes/lib
PHP
Directory includes/lib
account.php
check_weak_key.php
general.php
l10n.php
locale
Directory locale
C
cv.c
PHP
escape_special_chars.php
bash
makefile
pages
Directory pages
This directory only contains other (sub-) directorys, structured according to specific topics.
scripts
PHP
txt
Directory scripts
Directory stamp
certdet.php
common.php
displogo.php
.htaccess
index.php
old_showlogo.php.broken
report.php
showlogo.php
style.css
Directory stamp/images
CAverify.png
Directory tmp
Makefile
tverify
Directory tverify
favicon.ico
.htaccess
index
index.php
Directory tverify/index
0.php
1.php
WWW
PHP
Directory www
This contains the PHP code that is the entry point to the application: