Server Installation/Opennet CA: Unterschied zwischen den Versionen
→Webserver: Doku erledigt |
|||
| Zeile 210: | Zeile 210: | ||
* HTTP (ca) |
* HTTP (ca) |
||
<VirtualHost *:80> |
|||
TODO |
|||
ServerName ca.opennet-initiative.de |
|||
| ⚫ | |||
ServerAlias ca.on-i.de |
|||
TODO |
|||
ServerAlias ca.on |
|||
ServerAdmin admin@opennet-initiative.de |
|||
DocumentRoot /var/www/htdocs/ca.opennet-initiative.de |
|||
<Directory /> |
|||
Options FollowSymLinks |
|||
AllowOverride AuthConfig |
|||
</Directory> |
|||
<Directory /var/www/htdocs/ca.opennet-initiative.de> |
|||
Options Indexes FollowSymLinks MultiViews |
|||
AllowOverride AuthConfig |
|||
Order allow,deny |
|||
allow from all |
|||
</Directory> |
|||
ErrorLog /var/log/apache2/error.log |
|||
LogLevel warn |
|||
CustomLog /var/log/apache2/ca.log combined |
|||
</VirtualHost> |
|||
| ⚫ | |||
<IfModule mod_ssl.c> |
|||
<VirtualHost _default_:444> |
|||
ServerName ca.opennet-initiative.de |
|||
ServerAlias ca.on-i.de |
|||
ServerAlias ca.on |
|||
ServerAdmin admin@opennet-initiative.de |
|||
SSLEngine on |
|||
SSLCertificateFile /etc/ssl/certs/heartofgold_cert.pem |
|||
SSLCertificateKeyFile /etc/ssl/private/heartofgold_key.pem |
|||
SSLCACertificateFile /etc/apache2/ssl/root.crt |
|||
SSLCACertificatePath /etc/apache2/ssl/ |
|||
SSLCARevocationPath /etc/apache2/ssl/ |
|||
SSLCADNRequestPath /etc/apache2/ssl/ |
|||
DocumentRoot /var/www/htdocs/ca.opennet-initiative.de |
|||
Alias /internal /var/www/ca_internal |
|||
<Directory /> |
|||
Options FollowSymLinks |
|||
#AllowOverride AuthConfig |
|||
</Directory> |
|||
<Directory /var/www/htdocs/ca.opennet-initiative.de> |
|||
Options Indexes FollowSymLinks MultiViews |
|||
#AllowOverride AuthConfig |
|||
Order allow,deny |
|||
allow from all |
|||
</Directory> |
|||
<Directory /var/www/ca_internal> |
|||
Options Indexes FollowSymLinks MultiViews |
|||
#AllowOverride AuthConfig |
|||
Order allow,deny |
|||
allow from all |
|||
# client cert auth |
|||
SSLVerifyClient optional |
|||
SSLVerifyDepth 3 |
|||
# forward auth to php |
|||
SSLOptions +StdEnvVars |
|||
# allow specific cert CN |
|||
SSLRequire %{SSL_CLIENT_S_DN_CN} in {"xxx.client.on","yyy.client.on"} |
|||
# client cert error handling |
|||
RewriteEngine on |
|||
RewriteCond %{SSL:SSL_CLIENT_VERIFY} !=SUCCESS |
|||
RewriteRule .? - [F] |
|||
ErrorDocument 403 "You need a certificate issued by Opennet Client Sub-CA to access this site." |
|||
</Directory> |
|||
ErrorLog /var/log/apache2/error.log |
|||
LogLevel warn |
|||
CustomLog /var/log/apache2/ca.log combined |
|||
CustomLog /var/log/apache2/ca_clientcert.log \ |
|||
"%t %h SSL_CLIENT_S_DN = %{SSL_CLIENT_S_DN}x | \ |
|||
SSL_CLIENT_M_SERIAL = %{SSL_CLIENT_M_SERIAL}x | \ |
|||
SSL_PROTOCOL = %{SSL_PROTOCOL}x | SSL_CIPHER = %{SSL_CIPHER}x \ |
|||
%r %>s %b" |
|||
</VirtualHost> |
|||
</IfModule> |
|||
[[Kategorie:Server]] |
[[Kategorie:Server]] |
||
Version vom 16. März 2014, 16:00 Uhr
Software für Betrieb der Opennet CA.
Überblick
Die Opennet CA Software besteht aus drei Bereichen:
- Backend (Bash Shell Scripte), enthält alle notwendige OpenSSL Wrapper Scripte
- Frontend Webinterface (Static HTML u. PHP), Arbeit mit CSR Dateien kombiniert mit JSON Metadaten Dateien
- Frontend Batchscripte (Bash Shell Scripte), Schnittstelle zwischen Frontend u. Backend, dient der Automatisierung
Voraussetzungen
- openssl - zum Betrieb der CA Funktionen
- mutt - zum Versand von E-Mails
- apache2 - für Webseiten
- jq - für JSON
Funktionen
- Signieren von Zertifikatsanfragen
- Zurückziehen von Zertifikaten
- Erstellen der CRL Liste
- Download und CA Verifizierung einer CRL Liste
- Suchen von Zertifikaten über CN
- Logging und integriertes Backup
- automatischer Mailversand
- Erzeugen von Webübersicht
State Maschine
Beschreibung der verschiedenen Zustände in dem sich eine CSR Anfrage befinden kann und mit welchen Methoden durch Nutzerinteraktion (upload und csr_approve bzw. revoke_approve) oder automatische Prozesse (signbatch bzw. revokebatch) der Zustand gewechselt wird.
Abläufe
Sign:
- Nutzer läd Zertfikatsantrag (CSR) hoch per CSR Webinterface
- eine E-Mail an die CSR-Mailadresse wird versendet, enthält den Approve-Link
- ein CA Admin prüft und bestätigt den Zertifikatsantrag (CSR-Approve)
- ein Cronjob sucht bestätigte CSR Anfragen und startet den CA Signaturprozess
- beim erfolgreichen Signieren wird das Zertifikat per Mail versendet
- bei Fehlern wird dieses protokolliert, muss händisch beseitigt werden
- danach kann ggf. wieder über den CSR-Approve-Link fortgefahren werden
Revoke:
- ein CA Admin kann das Zurückziehen von Zertifikaten anfordern (Revoke-Approve)
- ein Cronjob sucht bestätigte Revoke Anfragen und startet den CA Revokeprozess
- beim erfolgreichen Zurückziehen wird eine Mail versendet
- bei Fehlern wird dieses protokolliert, muss händisch beseitigt werden
- danach kann ggf. wieder über den Revoke-Approve-Link fortgefahren werden
User u. Verzeichnisse
- User "opennetca" mit Home /home/opennetca
- Gruppenmitgliedschaft www-data hinzufügen:
usermod -a -G www-data opennetca
- CA Verzeichnis einrichten:
mkdir cert mkdir crl mkdir csr mkdir .backup touch index.txt touch serial.txt cp <src>/README . cp <src>/opennetca.sh . cp <src>/opennetca.conf . cp <src>/sign.sh . cp <src>/revoke.sh . cp <src>/crl.sh . cp <src>/opennet-*.crt . cp <src>/opennet-*.key . cp <src>/opennet-*.conf . chown -R opennetca:opennetca * chmod 600 opennet-*.key
- Öffentliche Webseiten unter /var/www/htdocs/ca.opennet-initiative.de/
- Interne Webseiten unter /var/www/ca_internal/
- Upload Verzeichnis unter /var/www/csr_upload/ - Rechte setzen:
chown www-data:www-data csr_upload chmod g+w csr_upload
Config Files
- OpenSSL Konfiguration: opennet-<ca-name>.ca.on_<year>.conf, notwendige Anpassungen:
[ opennetca ] dir = /home/opennetca/ca/<capath> certificate = $dir/opennet-<caname>.crt private_key = $dir/opennet-<caname>.key [ opennetca_certsign ] nsComment = Opennet <caname-text> CA nsCaRevocationUrl = http://ca.opennet-initiative.de/<caname>.crl nsRevocationUrl = http://ca.opennet-initiative.de/<caname>.crl [ opennetca_crl ] fullname=URI:http://ca.opennet-initiative.de/<caname>.crl
- CA Script Konfiguration: opennetca.cfg, notwendige Anpassungen:
# variables global CA_CONFIG=opennet-<caname>.conf CA_MAILSUBJECT="Opennet CA (<caname>)" # variables sign CA_CSRCN="<cn-extension1> <cn-extension2> .." # variables crl CA_CRL=<caname>.crl
CA Scripts
Download per Web: http://svn.opennet-initiative.de/listing.php?repname=on_opennetca
Checkout per SVN: svn checkout svn://svn.opennet-initiative.de/on_opennetca
- Opennet CA: opennetca.sh (Basisfunktionen, benötigt Konfiguration opennetca.conf)
- Zertifikat signieren: sign.sh (verwendet opennetca.sh sign Methode)
- Zertifikat zurückziehen: revoke.sh (verwendet opennetca.sh revoke Methode)
- CRL Liste erstellen: crl.sh (verwendet opennetca.sh crl Methode)
- Cert Suche: list.sh (verwendet opennetca.sh list Methode)
- Cert Liste in HTML: opennetca_htmlview.sh (eigenständiges Script)
- CRL Download: opennetca_crldownload.sh (eigenständiges Script, nur benötigt auf VPN Server)
- Zertifikat automatisch signieren: sign_batch.sh (verwendet opennetca.sh sign_batch Methode)
- Zertifikat automatisch zurückziehen: revoke_batch.sh (verwendet opennetca.sh revoke_batch Methode)
Diese Files für jede CA bereitstellen. Keine Anpassung notwendig.
CSR Scripts
Ergänzend zu den CA Scripts:
- CSR Upload: index.html und csr_upload.php (Hochladefunktion)
- CSR Liste in HTML: opennetcsr_htmlview.sh (Übersicht CSR Status und Approve Webinterface)
- CSR Sign Batch Prozess: opennetcsr_signbatch.sh (Approved CSRs anzeigen bzw. automatisch mit passender CA signieren)
- CSR Revoke Batch Prozess: opennetcsr_revokebatch.sh (Approved Revokes anzeigen bzw. automatisch mit passender CA zurückziehen)
CSR JSON
Zur Verwaltung des CSR Lebenszyklus:
{
"meta_type":"Opennet_CSR_JSON_v1",
"meta_created":"<Timestamp>",
"name":"<Filename>",
"subject_o":"<Name>",
"subject_cn":"<Node>",
"subject_mail":"<Mail>",
"digest":"<Digest>",
"cn_filter":"<CN-Filter>",
"upload_timestamp":"<Timestamp>",
"upload_advisor":"<Advisor-Name>",
"upload_ccmail":"<CC-Mail>",
"status":"CSR|Approved|Signed|Error|RevokeApproved|Revoked|RevokeError",
"approve_message":"<Message>",
"approve_timestamp":"<Timestamp>",
"sign_message":"<Message>",
"sign_timestamp":"<Timestamp>",
"revokeapprove_message":"<Message>",
"revokeapprove_timestamp":"<Timestamp>",
"revoke_message":"<Message>",
"revoke_timestamp":"<Timestamp>",
"error_message":"<Message>",
"error_timestamp":"<Timestamp>",
}
Cronjobs
Regelmäßige CRL Listen Erstellung und Bereitstellung:
# Opennet CA CRL Generator 15 1,13 * * * opennetca /home/opennetca/ca/root/crl.sh 2>/dev/null 15 1,13 * * * opennetca /home/opennetca/ca/vpnuser/crl.sh 2>/dev/null 15 1,13 * * * opennetca /home/opennetca/ca/vpnugw/crl.sh 2>/dev/null 15 1,13 * * * opennetca /home/opennetca/ca/client/crl.sh 2>/dev/null 25 1,13 * * * root cp /home/opennetca/ca/root/crl/*.crl /var/www/htdocs/ca.opennet-initiative.de/ 25 1,13 * * * root cp /home/opennetca/ca/vpnuser/crl/*.crl /var/www/htdocs/ca.opennet-initiative.de/ 25 1,13 * * * root cp /home/opennetca/ca/vpnugw/crl/*.crl /var/www/htdocs/ca.opennet-initiative.de/ 25 1,13 * * * root cp /home/opennetca/ca/client/crl/*.crl /var/www/htdocs/ca.opennet-initiative.de/
Inhaltliche CRL Kontrolle per (u.a. Revoked Certificates):
openssl crl -text -in crl/<crlfile>.crl -CAfile <cafile>.crt
Öffentliche anonymisierte und geschütze private Zertifikatsliste bereitstellen:
# Opennet CA Cert List Generator 30 1,13 * * * root /home/opennetca/ca/root/opennetca_htmlview.sh --public >/var/www/htdocs/ca.opennet-initiative.de/root.html 30 1,13 * * * root /home/opennetca/ca/root/opennetca_htmlview.sh --private >/var/www/ca_internal/root.html */10 * * * * root /home/opennetca/ca/vpnuser/opennetca_htmlview.sh --public >/var/www/htdocs/ca.opennet-initiative.de/vpnuser.html */10 * * * * root /home/opennetca/ca/vpnuser/opennetca_htmlview.sh --private >/var/www/ca_internal/vpnuser.html */10 * * * * root /home/opennetca/ca/vpnugw/opennetca_htmlview.sh --public >/var/www/htdocs/ca.opennet-initiative.de/vpnugw.html */10 * * * * root /home/opennetca/ca/vpnugw/opennetca_htmlview.sh --private >/var/www/ca_internal/vpnugw.html */10 * * * * root /home/opennetca/ca/client/opennetca_htmlview.sh --public >/var/www/htdocs/ca.opennet-initiative.de/client.html */10 * * * * root /home/opennetca/ca/client/opennetca_htmlview.sh --private >/var/www/ca_internal/client.html
Öffentliche anonymisierte und geschütze private CSR Statusliste bereitstellen:
# Opennet CSR List Generator */5 * * * * root /home/opennetca/csr/opennetcsr_htmlview.sh --public >/var/www/htdocs/ca.opennet-initiative.de/csr.html */5 * * * * root /home/opennetca/csr/opennetcsr_htmlview.sh --private >/var/www/ca_internal/csr.html
Automatisches Signieren von freigegeben CSR Anfragen (Status = Approved):
# Opennet CSR Sign Batch Job */5 * * * * opennetca /home/opennetca/csr/opennetcsr_signbatch.sh --sign >/dev/null 2>&1
Automatisches Zurückziehen von freigegeben Revoke Anfragen (Status = RevokeApproved):
# Opennet CSR Revoke Batch Job */5 * * * * opennetca /home/opennetca/csr/opennetcsr_revokebatch.sh --revoke >/dev/null 2>&1
Auf den Opennet VPN-Servern muss ebenfalls ein Cronjob angelegt werden, mm die CRLs regelmäßig zu aktualisieren. Details siehe Server Installation/OpenVPN.
Mailversand
Beim Hochladen über das CSR Webinterface csr_upload.php wird eine Benachrichtigung an die CSR-Mailadresse versendet. Empfänger und Absender sind im PHP-File konfigurierbar.
Beim Signieren und Revoken wird durch das opennetca.sh Script automatisch eine E-Mail generiert. Diese enthält stets das Zertifikat, einen kurzen Infotext sowie Metaangaben zum Zertifikat. Empfänger ist die Mailadresse im Zertifikat sowie die CSR-Mailadresse (konfigurierbar im Configfile) und die CC-Mailadresse (beim Hochladen des CSR festgelegt).
Als Absender der Mail wird der Username vom Server, unter dem die CA installiert ist, verwendet (hier: opennetca - AT - opennet-initiative.de). Zum Empfang von möglichen Rückantworten ist opennetca - AT - opennet-initiative.de daher mit Weiterleitung zu admin eingerichtet.
Webserver
- HTTP (ca)
<VirtualHost *:80>
ServerName ca.opennet-initiative.de
ServerAlias ca.on-i.de
ServerAlias ca.on
ServerAdmin admin@opennet-initiative.de
DocumentRoot /var/www/htdocs/ca.opennet-initiative.de
<Directory />
Options FollowSymLinks
AllowOverride AuthConfig
</Directory>
<Directory /var/www/htdocs/ca.opennet-initiative.de>
Options Indexes FollowSymLinks MultiViews
AllowOverride AuthConfig
Order allow,deny
allow from all
</Directory>
ErrorLog /var/log/apache2/error.log
LogLevel warn
CustomLog /var/log/apache2/ca.log combined
</VirtualHost>
- HTTPS (ca-ssl)
<IfModule mod_ssl.c>
<VirtualHost _default_:444>
ServerName ca.opennet-initiative.de
ServerAlias ca.on-i.de
ServerAlias ca.on
ServerAdmin admin@opennet-initiative.de
SSLEngine on
SSLCertificateFile /etc/ssl/certs/heartofgold_cert.pem
SSLCertificateKeyFile /etc/ssl/private/heartofgold_key.pem
SSLCACertificateFile /etc/apache2/ssl/root.crt
SSLCACertificatePath /etc/apache2/ssl/
SSLCARevocationPath /etc/apache2/ssl/
SSLCADNRequestPath /etc/apache2/ssl/
DocumentRoot /var/www/htdocs/ca.opennet-initiative.de
Alias /internal /var/www/ca_internal
<Directory />
Options FollowSymLinks
#AllowOverride AuthConfig
</Directory>
<Directory /var/www/htdocs/ca.opennet-initiative.de>
Options Indexes FollowSymLinks MultiViews
#AllowOverride AuthConfig
Order allow,deny
allow from all
</Directory>
<Directory /var/www/ca_internal>
Options Indexes FollowSymLinks MultiViews
#AllowOverride AuthConfig
Order allow,deny
allow from all
# client cert auth
SSLVerifyClient optional
SSLVerifyDepth 3
# forward auth to php
SSLOptions +StdEnvVars
# allow specific cert CN
SSLRequire %{SSL_CLIENT_S_DN_CN} in {"xxx.client.on","yyy.client.on"}
# client cert error handling
RewriteEngine on
RewriteCond %{SSL:SSL_CLIENT_VERIFY} !=SUCCESS
RewriteRule .? - [F]
ErrorDocument 403 "You need a certificate issued by Opennet Client Sub-CA to access this site."
</Directory>
ErrorLog /var/log/apache2/error.log
LogLevel warn
CustomLog /var/log/apache2/ca.log combined
CustomLog /var/log/apache2/ca_clientcert.log \
"%t %h SSL_CLIENT_S_DN = %{SSL_CLIENT_S_DN}x | \
SSL_CLIENT_M_SERIAL = %{SSL_CLIENT_M_SERIAL}x | \
SSL_PROTOCOL = %{SSL_PROTOCOL}x | SSL_CIPHER = %{SSL_CIPHER}x \
%r %>s %b"
</VirtualHost>
</IfModule>
