Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revisionLast revisionBoth sides next revision | ||
ssl-certs [2015/01/16 15:11] – brot | ssl-certs [2016/10/28 13:09] – rellig | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Informationen über die minad.de SSL-Zertifkikate ====== | ====== Informationen über die minad.de SSL-Zertifkikate ====== | ||
- | minad.de hat - wie jeder ordentliche Server SSL-Zertifikate um SSL-Gesicherten Datenaustausch zu ermöglichen. Zur Zeit verwenden wir selbstsignierte Zertifikate, | + | minad.de hat - wie jeder ordentliche Server SSL-Zertifikate um SSL-Gesicherten Datenaustausch zu ermöglichen. |
- | ===== Import des CA-Zertifikats | + | ===== Zertifikat Neuantrag |
- | Um den Warnungen über das " | + | Neue Zertifikate müssen nur einmal beantragt werden. Dafür hat sich folgender command etabliert: |
- | ==== Linux ==== | + | <file bash - > |
- | + | certbot certonly | |
- | <nowiki> | + | |
- | certutil | + | |
- | </nowiki> | + | |
- | + | ||
- | ==== Windows ==== | + | |
- | | + | |
- | | + | |
- | | + | |
- | - Doppelklick auf Zertifikate -> Rechtsklick auf " | + | |
- | - Das " | + | |
- | + | ||
- | Und schon sollte das Zertifikat importiert sein. Ein Kinderspiel, | + | |
- | + | ||
- | ==== Android ==== | + | |
- | + | ||
- | Android erwartet ein anderes Zertifikatsformat, | + | |
- | + | ||
- | | + | |
- | + | ||
- | Umwandeln könnte. Das wurde allerding schon erledigt und kann [[http:// | + | |
- | + | ||
- | Danach | + | |
- | + | ||
- | ===== Verwendung der Zertifikate auf dem Server ===== | + | |
- | Die Zertifikate liegen im Verzeichnis | + | |
- | + | ||
- | * minad.de-cert.pem | + | |
- | * minad.de-key.pem | + | |
- | * minad.de-chained-nopw.pem | + | |
- | + | ||
- | Das -cert ist das x509 Zertifikat. Das -key ist der Passwortverschlüsselte key. Unter Chained ist erst der nicht mit Passwort versehene Key, und dann das Zertifikat abgelegt. Letzeres ist die von den Serverdiensten verwendete Datei, da sonst bei jedem Neustart das Passwort eingegeben werden müsste. | + | |
- | + | ||
- | + | ||
- | ==== lighttpd ==== | + | |
- | + | ||
- | <file - / | + | |
- | $SERVER[" | + | |
- | | + | |
- | + | ||
- | | + | |
- | | + | |
- | + | ||
- | + | ||
- | | + | |
- | + | ||
- | | + | |
- | | + | |
- | | + | |
- | + | ||
- | } | + | |
</ | </ | ||
+ | | ||
+ | Hinweis: Nachdem es ein Limit von 20 renews pro Domain pro Woche gibt (domain in dem fall minad.de oder grilldienstag.de ohne jeweilige sub), bietet es sich an Domains logisch zusammenzufassen. | ||
- | ==== Postfix/ | + | Deswegen [[ssl_cert_list|hier eine Liste unserer Zertifikate inkl. der Domains für die sie gelten]]. |
- | < | + | ===== Zertifikate mit alternativen Namen ===== |
- | # we wannt secure connections | + | Ein Zertifikat mit alternativen Namen wird ähnlich ausgestellt wie ein Zertifikat für eine Domain. Weitere Domains werden einfach Komma-getrennt an die Option |
- | smtpd_tls_security_level = may | + | |
- | smtpd_tls_auth_only = yes | + | |
- | #new certs minad_selfsigned_v3 25.04 | + | <file bash - > |
- | smtpd_tls_cert_file = / | + | certbot certonly --agree-tos --renew-by-default --email root@minad.de --webroot -w /var/www/letsencrypt -d rellig.minad.de, |
- | smtpd_tls_key_file = $smtpd_tls_cert_file | + | |
- | + | ||
- | + | ||
- | #we want high encryption | + | |
- | # | + | |
- | smtpd_tls_mandatory_exclude_ciphers = aNULL, MD5 | + | |
- | smtpd_tls_mandatory_protocols = !SSLv2, !SSLv3 | + | |
- | + | ||
- | #ecliptic curve crypto? we has it | + | |
- | smtpd_tls_dh1024_param_file = /etc/postfix/dh_1024.pem | + | |
- | smtpd_tls_dh512_param_file = / | + | |
- | smtpd_tls_eecdh_grade = strong | + | |
- | + | ||
- | # outgoing mails shall also use tls | + | |
- | smtp_tls_security_level = may | + | |
- | smtp_tls_loglevel = 1 | + | |
</ | </ | ||
- | <file - /etc/dovecot/conf.d/10-ssl.conf> | + | Die erste Domain bestimmt den Pfad unter dem das Zertifikat gespeichert wird und ist gleichzeitig im Feld " |
- | ## | + | Sollen nachträglich weitere alternative Namen eingefügt werden, so nimmt man die __exakt gleiche__ Liste wie beim ausstellen und fügt den neuen Namen ein. Der certbot sollte nun fragen, ob das bestehende Zertifikat erweitert werden soll. Am Besten mit //--dry-run// testen.\\ |
- | ## SSL settings | + | |
- | ## | + | |
- | # SSL/TLS support: yes, no, required. < | + | Zum Überblick [[ssl_cert_list|hier eine Liste unserer Zertifikate inkl. der Domains für die sie gelten]]. |
- | ssl = required | + | |
- | # PEM encoded X.509 SSL/TLS certificate and private key. They' | + | ===== Automatisches Verlängern ===== |
- | # dropping root privileges, so keep the key file unreadable by anyone but | + | |
- | # root. Included doc/ | + | |
- | # certificate, | + | |
- | ssl_cert = </ | + | Das automatische renewal funktioniert über zwei Systemd-Units inkl. Timer, und ein Skript dass die Zertifikate für lighty zusammenbaut. |
- | ssl_key = </ | + | |
- | </ | + | |
- | ===== Erstellen der CA und der Zertifikate ===== | + | ==== certbot |
+ | <file bash certbot-renew.service> | ||
+ | [Unit] | ||
+ | Description=Call certbot to renew all certificates | ||
+ | After=network.target | ||
- | ==== Neu: StartSSL Zertifikate ==== | + | [Service] |
- | + | User=root | |
- | <file bash -> | + | Type=oneshot |
- | + | ExecStart=/ | |
- | minad minad_startssl_signed_v1 # openssl genrsa -out echorulez.key 4096 | + | |
- | Generating RSA private key, 4096 bit long modulus | + | |
- | minad minad_startssl_signed_v1 # openssl req -new -sha256 -key echorulez.key -out echorulez.csr | + | |
- | You are about to be asked to enter information that will be incorporated | + | |
- | into your certificate request. | + | |
- | What you are about to enter is what is called a Distinguished Name or a DN. | + | |
- | There are quite a few fields but you can leave some blank | + | |
- | For some fields there will be a default value, | + | |
- | If you enter ' | + | |
- | ----- | + | |
- | Country Name (2 letter code) [DE]: | + | |
- | State or Province Name (full name) [Bavaria]: | + | |
- | Locality Name (eg, city) []: | + | |
- | Organization Name (eg, company) []: | + | |
- | Organizational Unit Name (eg, section) []: | + | |
- | first Common Name (eg, YOUR name) [echorulez.de]: | + | |
- | Email Address [root@echorulez.de]: | + | |
- | + | ||
- | Please enter the following ' | + | |
- | to be sent with your certificate request | + | |
- | A challenge password []: | + | |
- | An optional company name []: | + | |
- | + | ||
- | *einreichen des csr bei startssl* | + | |
- | + | ||
- | minad minad_startssl_signed_v1 # cat echorulez.key echorulez.crt > echorulez.pem | + | |
- | minad minad_startssl_signed_v1 # cat sub.class2.server.ca.pem ca.pem > ca-chain.pem | + | |
</ | </ | ||
- | ==== Einstellungen der openssl.cnf ==== | + | <file bash certbot-renew.timer> |
- | Die Einstellungen betreffen primär die vorgegebenen Werte, sowie das erstellen von Zertifikaten mit SAN (subject alternate names). Möchte man ein Zertifikat für mehr als eine Domain ausstellen, so geht das mit der besagten Erweiterung. | + | [Unit] |
+ | Description=Timer for the sslscript - currently daily | ||
- | In der CA_default Sektion: | + | [Timer] |
+ | OnCalendar=Wed *-*-* 10:07:00 | ||
- | <file - / | + | [Install] |
- | [ CA_default | + | WantedBy=timer.target |
- | (...) | + | |
- | # Extension copying option: use with caution. | + | |
- | | + | |
- | (...) | + | |
- | default_days | + | |
- | default_crl_days= 30 # how long before next CRL | + | |
- | default_md | + | |
- | preserve | + | |
</ | </ | ||
- | Und in der " | + | ==== sslscript ==== |
- | <file - / | + | |
- | [ req ] | + | |
- | default_bits | + | |
- | default_keyfile | + | |
- | distinguished_name | + | |
- | attributes | + | |
- | x509_extensions | + | |
- | # brot - subject alternate name | + | Das Skript dass das für den lighty zusammenpastet und kopiert siehe [[https:// |
- | req_extensions = v3_req # The extensions to add to a certificate request | + | |
- | (...) | + | <file bash sslscript.service> |
+ | [Unit] | ||
+ | Description=Check if there are renewed SSL-Certs and convert them for lighty | ||
+ | After=network.target | ||
- | [ req_distinguished_name | + | [Service] |
- | countryName | + | User=root |
- | countryName_default | + | Type=oneshot |
- | countryName_min | + | ExecStart=/root/ |
- | countryName_max | + | |
- | + | ||
- | stateOrProvinceName | + | |
- | stateOrProvinceName_default | + | |
- | + | ||
- | localityName | + | |
- | + | ||
- | 0.organizationName | + | |
- | 0.organizationName_default | + | |
- | + | ||
- | # we can do this but it is not needed normally :-) | + | |
- | # | + | |
- | # | + | |
- | + | ||
- | organizationalUnitName | + | |
- | # | + | |
- | + | ||
- | 0.commonName | + | |
- | 0.commonName_max | + | |
- | 0.commonName_default | + | |
- | + | ||
- | emailAddress | + | |
- | emailAddress_max | + | |
- | emailAddress_default | + | |
- | + | ||
- | (...) | + | |
</ | </ | ||
- | Und für die SANs an sich folgender Eintrag: | + | < |
- | < | + | [Unit] |
- | [ v3_req | + | Description=Timer for the sslscript - currently daily |
- | # Extensions to add to a certificate request | + | [Timer] |
+ | OnCalendar=Tue *-*-* 10:07:00 | ||
- | basicConstraints = CA:FALSE | + | [Install] |
- | keyUsage | + | WantedBy=timer.target |
- | + | ||
- | # brot - subject alt name | + | |
- | subjectAltName = DNS: | + | |
</ | </ | ||
- | |||
- | |||
- | <file bash -> | ||
- | |||
- | minad minad_selfsigned_v3 # / | ||
- | CA certificate filename (or enter to create) | ||
- | |||
- | Making CA certificate ... | ||
- | Generating a 8192 bit RSA private key | ||
- | .......................................................................................................................................................................++ | ||
- | .......................................................................................................................................................................................................................++ | ||
- | writing new private key to ' | ||
- | Enter PEM pass phrase: | ||
- | Verifying - Enter PEM pass phrase: | ||
- | ----- | ||
- | You are about to be asked to enter information that will be incorporated | ||
- | into your certificate request. | ||
- | What you are about to enter is what is called a Distinguished Name or a DN. | ||
- | There are quite a few fields but you can leave some blank | ||
- | For some fields there will be a default value, | ||
- | If you enter ' | ||
- | ----- | ||
- | Country Name (2 letter code) [DE]: | ||
- | State or Province Name (full name) [Bavaria]: | ||
- | Locality Name (eg, city) []: | ||
- | Organization Name (eg, company) [minad]: | ||
- | Organizational Unit Name (eg, section) []: | ||
- | first Common Name (eg, YOUR name) [minad.de]: | ||
- | Email Address [root@minad.de]: | ||
- | |||
- | Please enter the following ' | ||
- | to be sent with your certificate request | ||
- | A challenge password []: | ||
- | An optional company name []: | ||
- | Using configuration from / | ||
- | Enter pass phrase for ./ | ||
- | Check that the request matches the signature | ||
- | Signature ok | ||
- | Certificate Details: | ||
- | Serial Number: 14186275591684022291 (0xc4dfc67d101ee013) | ||
- | Validity | ||
- | Not Before: Apr 25 09:10:49 2014 GMT | ||
- | Not After : Apr 22 09:10:49 2024 GMT | ||
- | Subject: | ||
- | countryName | ||
- | stateOrProvinceName | ||
- | organizationName | ||
- | commonName | ||
- | emailAddress | ||
- | X509v3 extensions: | ||
- | X509v3 Subject Key Identifier: | ||
- | 29: | ||
- | X509v3 Authority Key Identifier: | ||
- | keyid: | ||
- | |||
- | X509v3 Basic Constraints: | ||
- | CA:TRUE | ||
- | Certificate is to be certified until Apr 22 09:10:49 2024 GMT (3650 days) | ||
- | |||
- | Write out database with 1 new entries | ||
- | Data Base Updated | ||
- | minad minad_selfsigned_v3 # / | ||
- | Generating a 8192 bit RSA private key | ||
- | .................................++ | ||
- | ...........................................................................................................................................................................................................................................................................................................++ | ||
- | writing new private key to ' | ||
- | Enter PEM pass phrase: | ||
- | Verifying - Enter PEM pass phrase: | ||
- | ----- | ||
- | You are about to be asked to enter information that will be incorporated | ||
- | into your certificate request. | ||
- | What you are about to enter is what is called a Distinguished Name or a DN. | ||
- | There are quite a few fields but you can leave some blank | ||
- | For some fields there will be a default value, | ||
- | If you enter ' | ||
- | ----- | ||
- | Country Name (2 letter code) [DE]: | ||
- | State or Province Name (full name) [Bavaria]: | ||
- | Locality Name (eg, city) []: | ||
- | Organization Name (eg, company) [minad]: | ||
- | Organizational Unit Name (eg, section) []: | ||
- | first Common Name (eg, YOUR name) [minad.de]: | ||
- | Email Address [root@minad.de]: | ||
- | |||
- | Please enter the following ' | ||
- | to be sent with your certificate request | ||
- | A challenge password []: | ||
- | An optional company name []: | ||
- | Request is in newreq.pem, private key is in newkey.pem | ||
- | minad minad_selfsigned_v3 # rm newreq.pem | ||
- | minad minad_selfsigned_v3 # mv newkey.pem minad.de-key.pem | ||
- | minad minad_selfsigned_v3 # mv newcert.pem minad.de-cert.pem | ||
- | minad minad_selfsigned_v3 # openssl rsa -in minad.de-key.pem -out minad.de-chained-nopw.pem | ||
- | Enter pass phrase for minad.de-key.pem: | ||
- | writing RSA key | ||
- | minad minad_selfsigned_v3 # openssl x509 -in minad.de-cert.pem >> minad.de-chained-nopw.pem | ||
- | minad minad_selfsigned_v3 # ln -sv demoCA/ | ||
- | </ | ||
- | |||
- | |||
- | |||