Benutzer-Werkzeuge

Webseiten-Werkzeuge


tachtler:apache_http_server_centos_7_-_mod_ssl_-_verschluesselung_https

Dies ist eine alte Version des Dokuments!


Apache HTTP Server CentOS 7 - mod_ssl - Verschlüsselung (https)

Das Apache HTTP Server-Modul mod_ssl wird benötigt um HTTP Kommunikation verschlüsselt betreiben zu können. Die Seitenaufrufe werden nicht mehr via http auf Port 80 erreicht, sonder via https auf Port 443. Um eine HTTP Kommunikation verschlüsselt betreiben zu können, sind zwei weitere Komponenten erforderlich, nämlich ein Schlüssel und ein Zertifikat.

:!: WICHTIG - Nachfolgende Konfigurationen setzen die Einrichtung eines Apache HTTP Servers, wie unter nachfolgendem internen Link beschrieben, voraus:

Ab hier werden root-Rechte zur Ausführung der nachfolgenden Befehle benötigt. Um root zu werden geben Sie bitte folgenden Befehl ein:

$ su -
Password: 

iptables Regel

Damit der Apache HTTP Server auch erreichbar ist und nicht die verschlüsselten Web-Anfragen vom Paketfilter iptables blockiert werden, muss nachfolgende Regel zum iptables-Regelwerk hinzugefügt werden.

Um die aktuellen iptables-Regeln erweitern zu können, sollten diese erst einmal aufgelistet werden, was mit nachfolgendem Befehl durchgeführt werden kann:

# iptables -L -nv --line-numbers
Chain INPUT (policy ACCEPT 0 packets, 0 bytes)
num   pkts bytes target     prot opt in     out   source       destination         
1       70  5752 ACCEPT     all  --  *      *     0.0.0.0/0    0.0.0.0/0      state RELATED,ESTABLISHED 
2        0     0 ACCEPT     icmp --  *      *     0.0.0.0/0    0.0.0.0/0           
3        0     0 ACCEPT     all  --  lo     *     0.0.0.0/0    0.0.0.0/0           
4        0     0 ACCEPT     tcp  --  *      *     0.0.0.0/0    0.0.0.0/0      state NEW tcp dpt:22 
5        0     0 ACCEPT     tcp  --  *      *     0.0.0.0/0    0.0.0.0/0      tcp dpt:80 
6        0     0 REJECT     all  --  *      *     0.0.0.0/0    0.0.0.0/0      reject-with icmp-host-prohibited 

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
num   pkts bytes target     prot opt in     out   source       destination         
1        0     0 REJECT     all  --  *      *     0.0.0.0/0    0.0.0.0/0      reject-with icmp-host-prohibited 

Chain OUTPUT (policy ACCEPT 0 packets, 0 bytes)
num   pkts bytes target     prot opt in     out   source       destination

Nachfolgender Befehl, fügt folgende iptables-Regel dem iptables-Regelwerk nach der Position 6 hinzu, ohne das der Paketfilter angehalten werden muss:

  • -A INPUT -p tcp --dport 443 -j ACCEPT

und hier die Befehle:

# iptables -I INPUT 6 -p tcp --dport 443 -j ACCEPT

Ein erneute Abfrage des iptables-Regelwerts, sollte dann nachfolgend dargestellte Ausgabe ergeben, was mit folgendem Befehl durchgeführt werden kann:

# iptables -L -nv --line-numbers
Chain INPUT (policy ACCEPT 0 packets, 0 bytes)
num   pkts bytes target     prot opt in     out   source       destination         
1       70  5752 ACCEPT     all  --  *      *     0.0.0.0/0    0.0.0.0/0      state RELATED,ESTABLISHED 
2        0     0 ACCEPT     icmp --  *      *     0.0.0.0/0    0.0.0.0/0           
3        0     0 ACCEPT     all  --  lo     *     0.0.0.0/0    0.0.0.0/0           
4        0     0 ACCEPT     tcp  --  *      *     0.0.0.0/0    0.0.0.0/0      state NEW tcp dpt:22 
5        0     0 ACCEPT     tcp  --  *      *     0.0.0.0/0    0.0.0.0/0      tcp dpt:80
6        0     0 ACCEPT     tcp  --  *      *     0.0.0.0/0    0.0.0.0/0      tcp dpt:443  
7        0     0 REJECT     all  --  *      *     0.0.0.0/0    0.0.0.0/0      reject-with icmp-host-prohibited 

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
num   pkts bytes target     prot opt in     out   source       destination         
1        0     0 REJECT     all  --  *      *     0.0.0.0/0    0.0.0.0/0      reject-with icmp-host-prohibited 

Chain OUTPUT (policy ACCEPT 0 packets, 0 bytes)
num   pkts bytes target     prot opt in     out   source       destination

Die neue Zeile ist an Position 6 (INPUT) zu sehen, hier nachfolgend zur Verdeutlichung noch einmal dargestellt (nur relevanter Ausschnitt):

...
6        0     0 ACCEPT     tcp  --  *      *     0.0.0.0/0    0.0.0.0/0      tcp dpt:443
...

Um diese iptables-Regel dauerhaft, auch nach einem Neustart des Server, weiterhin im iptables-Regelwerk zu speichern, muss nachfolgend dargestellter Befehl abschließend noch ausgeführt werden:

# /usr/sbin/iptables-save > /etc/sysconfig/iptables 

Installation

Zur Installation des Apache HTTP Server-Moduls mod_ssl muss nachfolgendes Paket

  • mod_ssl - ist im base-Repository von CentOS enthalten

installiert werden.

Mit nachfolgendem Befehl, wird das Pakete mod_ssl installiert:

# yum install mod_ssl
Loaded plugins: changelog, priorities
61 packages excluded due to repository priority protections
Resolving Dependencies
--> Running transaction check
---> Package mod_ssl.x86_64 1:2.4.6-18.el7.centos will be installed
--> Finished Dependency Resolution

Changes in packages about to be updated:


Dependencies Resolved

================================================================================
 Package        Arch          Version                      Repository      Size
================================================================================
Installing:
 mod_ssl        x86_64        1:2.4.6-18.el7.centos        updates         97 k

Transaction Summary
================================================================================
Install  1 Package

Total download size: 97 k
Installed size: 219 k
Is this ok [y/d/N]: y
Downloading packages:
mod_ssl-2.4.6-18.el7.centos.x86_64.rpm                     |  97 kB   00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : 1:mod_ssl-2.4.6-18.el7.centos.x86_64                         1/1
  Verifying  : 1:mod_ssl-2.4.6-18.el7.centos.x86_64                         1/1

Installed:
  mod_ssl.x86_64 1:2.4.6-18.el7.centos

Complete!

Mit nachfolgendem Befehl kann überprüft werden, welche Inhalte mit dem Paket mod_ssl installiert wurden.

# rpm -qil mod_ssl
Name        : mod_ssl
Epoch       : 1
Version     : 2.4.6
Release     : 18.el7.centos
Architecture: x86_64
Install Date: Wed 26 Nov 2014 05:42:20 AM CET
Group       : System Environment/Daemons
Size        : 224652
License     : ASL 2.0
Signature   : RSA/SHA256, Wed 23 Jul 2014 05:21:47 PM CEST, Key ID 24c6a8a7f4a80eb5
Source RPM  : httpd-2.4.6-18.el7.centos.src.rpm
Build Date  : Wed 23 Jul 2014 04:49:10 PM CEST
Build Host  : worker1.bsys.centos.org
Relocations : (not relocatable)
Packager    : CentOS BuildSystem <http://bugs.centos.org>
Vendor      : CentOS
URL         : http://httpd.apache.org/
Summary     : SSL/TLS module for the Apache HTTP Server
Description :
The mod_ssl module provides strong cryptography for the Apache Web
server via the Secure Sockets Layer (SSL) and Transport Layer
Security (TLS) protocols.
/etc/httpd/conf.d/ssl.conf
/etc/httpd/conf.modules.d/00-ssl.conf
/usr/lib64/httpd/modules/mod_ssl.so
/usr/libexec/httpd-ssl-pass-dialog
/var/cache/httpd/ssl

Konfiguration

Die Konfiguration des Apache HTTP Server-Moduls mod_ssl wird primär in nachfolgenden Konfigurationsdateien durchgeführt:

  • /etc/httpd/conf.modules.d/00-ssl.conf
  • /etc/httpd/conf.d/ssl.conf

Zusätzlich wurden noch eine Schlüssel und das dazugehörige Zertifikat bei der Installation erstellt. Die Dateien befinden sich in nachfolgenden Verzeichnissen und tragen nachfolgende Namen:

  • /etc/pki/tls/private/localhost.key
  • /etc/pki/tls/certs/localhost.crt

/etc/httpd/conf.modules.d/00-ssl.conf

Die Konfigurationsdatei /etc/httpd/conf.modules.d/00-ssl.conf beinhaltet die Integration des mod_ssl in den Apache HTTP Server.

:!: HINWEIS - Hier werden aktuell KEINE Anpassungen vorgenommen, da nur das Laden des Apache HTTP Server-Moduls mod_ssl in dieser Konfigurationsdatei konfiguriert wird!

(komplette Konfigurationsdatei)

LoadModule ssl_module modules/mod_ssl.so

/etc/httpd/conf.d/ssl.conf

Nachfolgend soll die Konfigurationsdatei

Konfigurationsdatei Beschreibung
ssl.conf Konfiguration des Einsatzes von Verschlüsselung https.

entsprechend angepasst werden.

:!: HINWEIS - Die nachfolgenden Anpassungen sind individuell und vom jeweiligen Einsatzzweck abhängig und ggf. den persönlichen Bedürfnissen anzupassen!

Die Anpassungen werden mit einem vorangestellten Kommentar in der Form

# Tachtler

gekennzeichnet.

(komplette Konfigurationsdatei)

#
# When we also provide SSL we have to listen to the
# the HTTPS port in addition.
#
# Tachtler
# default: Listen 443 https
Listen 192.168.1.90:443 https
Listen 192.168.0.90:443 https
 
##
##  SSL Global Context
##
##  All SSL configuration in this context applies both to
##  the main server and all SSL-enabled virtual hosts.
##
 
#   Pass Phrase Dialog:
#   Configure the pass phrase gathering process.
#   The filtering dialog program (`builtin' is a internal
#   terminal dialog) has to provide the pass phrase on stdout.
SSLPassPhraseDialog exec:/usr/libexec/httpd-ssl-pass-dialog
 
#   Inter-Process Session Cache:
#   Configure the SSL Session Cache: First the mechanism
#   to use and second the expiring timeout (in seconds).
SSLSessionCache         shmcb:/run/httpd/sslcache(512000)
SSLSessionCacheTimeout  300
 
#   Pseudo Random Number Generator (PRNG):
#   Configure one or more sources to seed the PRNG of the
#   SSL library. The seed data should be of good random quality.
#   WARNING! On some platforms /dev/random blocks if not enough entropy
#   is available. This means you then cannot use the /dev/random device
#   because it would lead to very long connection times (as long as
#   it requires to make more entropy available). But usually those
#   platforms additionally provide a /dev/urandom device which doesn't
#   block. So, if available, use this one instead. Read the mod_ssl User
#   Manual for more details.
SSLRandomSeed startup file:/dev/urandom  256
SSLRandomSeed connect builtin
#SSLRandomSeed startup file:/dev/random  512
#SSLRandomSeed connect file:/dev/random  512
#SSLRandomSeed connect file:/dev/urandom 512
 
#
# Use "SSLCryptoDevice" to enable any supported hardware
# accelerators. Use "openssl engine -v" to list supported
# engine names.  NOTE: If you enable an accelerator and the
# server does not start, consult the error logs and ensure
# your accelerator is functioning properly.
#
SSLCryptoDevice builtin
#SSLCryptoDevice ubsec
 
##
## SSL Virtual Host Context
##
 
<VirtualHost _default_:443>
 
# General setup for the virtual host, inherited from global configuration
#DocumentRoot "/var/www/html"
#ServerName www.example.com:443
 
# Use separate log files for the SSL virtual host; note that LogLevel
# is not inherited from httpd.conf.
ErrorLog logs/ssl_error_log
TransferLog logs/ssl_access_log
LogLevel warn
 
#   SSL Engine Switch:
#   Enable/Disable SSL for this virtual host.
SSLEngine on
 
#   SSL Protocol support:
# List the enable protocol levels with which clients will be able to
# connect.  Disable SSLv2 access by default:
# Tachtler
# default: SSLProtocol all -SSLv2
SSLProtocol -all +TLSv1 +TLSv1.1 +TLSv1.2
 
#   SSL Cipher Suite:
#   List the ciphers that the client is permitted to negotiate.
#   See the mod_ssl documentation for a complete list.
# Tachtler
# default: SSLCipherSuite HIGH:MEDIUM:!aNULL:!MD5
SSLCipherSuite ALL:HIGH:!MEDIUM:!LOW:!aNULL:!ADH:!eNULL:!EXP:!RC4:!MD5
 
#   Speed-optimized SSL Cipher configuration:
#   If speed is your main concern (on busy HTTPS servers e.g.),
#   you might want to force clients to specific, performance
#   optimized ciphers. In this case, prepend those ciphers
#   to the SSLCipherSuite list, and enable SSLHonorCipherOrder.
#   Caveat: by giving precedence to RC4-SHA and AES128-SHA
#   (as in the example below), most connections will no longer
#   have perfect forward secrecy - if the server's key is
#   compromised, captures of past or future traffic must be
#   considered compromised, too.
#SSLCipherSuite RC4-SHA:AES128-SHA:HIGH:MEDIUM:!aNULL:!MD5
# Tachtler
# default: #SSLHonorCipherOrder on
SSLHonorCipherOrder on
 
#   Server Certificate:
# Point SSLCertificateFile at a PEM encoded certificate.  If
# the certificate is encrypted, then you will be prompted for a
# pass phrase.  Note that a kill -HUP will prompt again.  A new
# certificate can be generated using the genkey(1) command.
SSLCertificateFile /etc/pki/tls/certs/localhost.crt
 
#   Server Private Key:
#   If the key is not combined with the certificate, use this
#   directive to point at the key file.  Keep in mind that if
#   you've both a RSA and a DSA private key you can configure
#   both in parallel (to also allow the use of DSA ciphers, etc.)
SSLCertificateKeyFile /etc/pki/tls/private/localhost.key
 
#   Server Certificate Chain:
#   Point SSLCertificateChainFile at a file containing the
#   concatenation of PEM encoded CA certificates which form the
#   certificate chain for the server certificate. Alternatively
#   the referenced file can be the same as SSLCertificateFile
#   when the CA certificates are directly appended to the server
#   certificate for convinience.
#SSLCertificateChainFile /etc/pki/tls/certs/server-chain.crt
 
#   Certificate Authority (CA):
#   Set the CA certificate verification path where to find CA
#   certificates for client authentication or alternatively one
#   huge file containing all of them (file must be PEM encoded)
#SSLCACertificateFile /etc/pki/tls/certs/ca-bundle.crt
 
#   Client Authentication (Type):
#   Client certificate verification type and depth.  Types are
#   none, optional, require and optional_no_ca.  Depth is a
#   number which specifies how deeply to verify the certificate
#   issuer chain before deciding the certificate is not valid.
#SSLVerifyClient require
#SSLVerifyDepth  10
 
#   Access Control:
#   With SSLRequire you can do per-directory access control based
#   on arbitrary complex boolean expressions containing server
#   variable checks and other lookup directives.  The syntax is a
#   mixture between C and Perl.  See the mod_ssl documentation
#   for more details.
#<Location />
#SSLRequire (    %{SSL_CIPHER} !~ m/^(EXP|NULL)/ \
#            and %{SSL_CLIENT_S_DN_O} eq "Snake Oil, Ltd." \
#            and %{SSL_CLIENT_S_DN_OU} in {"Staff", "CA", "Dev"} \
#            and %{TIME_WDAY} >= 1 and %{TIME_WDAY} <= 5 \
#            and %{TIME_HOUR} >= 8 and %{TIME_HOUR} <= 20       ) \
#           or %{REMOTE_ADDR} =~ m/^192\.76\.162\.[0-9]+$/
#</Location>
 
#   SSL Engine Options:
#   Set various options for the SSL engine.
#   o FakeBasicAuth:
#     Translate the client X.509 into a Basic Authorisation.  This means that
#     the standard Auth/DBMAuth methods can be used for access control.  The
#     user name is the `one line' version of the client's X.509 certificate.
#     Note that no password is obtained from the user. Every entry in the user
#     file needs this password: `xxj31ZMTZzkVA'.
#   o ExportCertData:
#     This exports two additional environment variables: SSL_CLIENT_CERT and
#     SSL_SERVER_CERT. These contain the PEM-encoded certificates of the
#     server (always existing) and the client (only existing when client
#     authentication is used). This can be used to import the certificates
#     into CGI scripts.
#   o StdEnvVars:
#     This exports the standard SSL/TLS related `SSL_*' environment variables.
#     Per default this exportation is switched off for performance reasons,
#     because the extraction step is an expensive operation and is usually
#     useless for serving static content. So one usually enables the
#     exportation for CGI and SSI requests only.
#   o StrictRequire:
#     This denies access when "SSLRequireSSL" or "SSLRequire" applied even
#     under a "Satisfy any" situation, i.e. when it applies access is denied
#     and no other module can change it.
#   o OptRenegotiate:
#     This enables optimized SSL connection renegotiation handling when SSL
#     directives are used in per-directory context.
#SSLOptions +FakeBasicAuth +ExportCertData +StrictRequire
<Files ~ "\.(cgi|shtml|phtml|php3?)$">
    SSLOptions +StdEnvVars
</Files>
<Directory "/var/www/cgi-bin">
    SSLOptions +StdEnvVars
</Directory>
 
#   SSL Protocol Adjustments:
#   The safe and default but still SSL/TLS standard compliant shutdown
#   approach is that mod_ssl sends the close notify alert but doesn't wait for
#   the close notify alert from client. When you need a different shutdown
#   approach you can use one of the following variables:
#   o ssl-unclean-shutdown:
#     This forces an unclean shutdown when the connection is closed, i.e. no
#     SSL close notify alert is send or allowed to received.  This violates
#     the SSL/TLS standard but is needed for some brain-dead browsers. Use
#     this when you receive I/O errors because of the standard approach where
#     mod_ssl sends the close notify alert.
#   o ssl-accurate-shutdown:
#     This forces an accurate shutdown when the connection is closed, i.e. a
#     SSL close notify alert is send and mod_ssl waits for the close notify
#     alert of the client. This is 100% SSL/TLS standard compliant, but in
#     practice often causes hanging connections with brain-dead browsers. Use
#     this only for browsers where you know that their SSL implementation
#     works correctly.
#   Notice: Most problems of broken clients are also related to the HTTP
#   keep-alive facility, so you usually additionally want to disable
#   keep-alive for those clients, too. Use variable "nokeepalive" for this.
#   Similarly, one has to force some clients to use HTTP/1.0 to workaround
#   their broken HTTP/1.1 implementation. Use variables "downgrade-1.0" and
#   "force-response-1.0" for this.
BrowserMatch "MSIE [2-5]" \
         nokeepalive ssl-unclean-shutdown \
         downgrade-1.0 force-response-1.0
 
#   Per-Server Logging:
#   The home of a custom SSL log file. Use this when you want a
#   compact non-error SSL logfile on a virtual host basis.
CustomLog logs/ssl_request_log \
          "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
 
</VirtualHost>

Erklärungen:

Listen

Setzen der IP-Adressen und des jeweiligen Ports, auf denen der Apache HTTP Server lauschen soll. Eine Mehrfachdefinition ist, wie dargestellt, ebenfalls möglich!

# Tachtler
# default: Listen 443 https
Listen 192.168.1.90:443 https
Listen 192.168.0.90:443 https

SSLProtocol

Angabe, welche der SSL-Protokoll-Typen unterstützt werden sollen.

Siehe auch den externen Link: (SSL) - http://httpd.apache.org/docs/current/mod/mod_ssl.html#sslprotocol
Siehe auch den externen Link: (Poodle) - https://access.redhat.com/solutions/1232413

# Tachtler
# default: SSLProtocol all -SSLv2
SSLProtocol -all +TLSv1 +TLSv1.1 +TLSv1.2

SSLCipherSuite

Angabe, welche Verschlüsselungs-Typen unterstützt werden sollen.

Siehe auch den externen Link: http://httpd.apache.org/docs/current/mod/mod_ssl.html#sslciphersuite

# Tachtler
# default: SSLCipherSuite HIGH:MEDIUM:!aNULL:!MD5
SSLCipherSuite ALL:HIGH:!MEDIUM:!LOW:!aNULL:!ADH:!eNULL:!EXP:!RC4:!MD5

SSLHonorCipherOrder

Bestimmt, das die Reihenfolge, in der die unterstützten Verschlüsselungs-Typen aufgeführt sind, bei der Verwendung eingehalten wird. Zuerst genannte werden vor den nachfolgenden angezogen.

# Tachtler
# default: #SSLHonorCipherOrder on
SSLHonorCipherOrder on

Neustart

Bevor weitere Konfigurationsschritte erfolgen, sollte einem Neustart nichts im Wege stehen:

# systemctl restart httpd.service

:!: HINWEIS - Es erfolgen keine weiteren Ausgaben, wenn der Start erfolgreich war !

Neustart Überprüfung

Ob die Verbindung vom Browser zum Apache HTTP Server nun auch verschlüsselt erfolgt, kann durch nachfolgende Befehle und URL-Aufrufe überprüft werden.

Nachfolgender Befehl listet die IP-Adressen und die Ports auf, auf denen der Apache HTTP Server lauscht und Anfragen beantwortet:

# netstat -tulpen | grep httpd
tcp        0      0 192.168.0.90:443       0.0.0.0:*         LISTEN      0       111932    16039/httpd         
tcp        0      0 192.168.1.90:443       0.0.0.0:*         LISTEN      0       111930    16039/httpd         
tcp        0      0 192.168.1.90:80        0.0.0.0:*         LISTEN      0       111924    16039/httpd         
tcp        0      0 192.168.0.90:80        0.0.0.0:*         LISTEN      0       111922    16039/httpd

Nachfolgender Befehl gibt die LOG-Meldungen aus, welche den Neustart des Apache HTTP Server protokolliert haben und sind in der LOG-Datei - /var/log/httpd/error_log - zu finden und sollten in etwa wie nachfolgende Einträge aussehen:

[Wed Nov 26 06:56:59.768849 2014] [mpm_prefork:notice] [pid 15513] AH00170: caught SIGWINCH, shutting down gracefully
[Wed Nov 26 06:57:00.865474 2014] [mpm_prefork:notice] [pid 16039] AH00163: Apache/2.4.6 (CentOS) OpenSSL/1.0.1e-fips configured -- resuming normal operations
[Wed Nov 26 06:57:00.865505 2014] [core:notice] [pid 16039] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'

Konfiguration überprüfen

In oben gezeigtem Beispiel in der Konfigurationsdatei

  • /etc/httpd/conf.d/ssl.conf

wurde ein Self-signed-certificate hinterlegt, welches in nachfolgende Konfigurationszeilen konfiguriert wurde:

(nur relevanter Ausschnitt)

...
#   Server Certificate:
#   Point SSLCertificateFile at a PEM encoded certificate.  If
#   the certificate is encrypted, then you will be prompted for a
#   pass phrase.  Note that a kill -HUP will prompt again.  A new
#   certificate can be generated using the genkey(1) command.
SSLCertificateFile /etc/pki/tls/certs/localhost.crt
 
#   Server Private Key:
#   If the key is not combined with the certificate, use this
#   directive to point at the key file.  Keep in mind that if
#   you've both a RSA and a DSA private key you can configure
#   both in parallel (to also allow the use of DSA ciphers, etc.)
SSLCertificateKeyFile /etc/pki/tls/private/localhost.key
...

Mit nachfolgenden Seitenaufrufen kann überprüft werden, ob die Änderungen durch die Einbindung der zusätzlichen Konfigurationsdateien erfolgreich war:

Der Aufruf der URL:

sollte nachfolgende Anzeige zum Vorschein bringen:

CentOS-7 - Apache - mod_ssl -Self-signet-certificate - Fehler - Seite 1

:!: HINWEIS - Die Fehlermeldung ist normal, da hier ein selbst erstelltes Zertifikat, welches auch noch einen anderen CN (Common Name) als die aufgerufene URL hat, verwendet wird!

Durch anklicken der Fehlermeldung im Bereich [I Understand the Risks], sollte nachfolgende Seite zur Anzeige kommen:

CentOS-7 - Apache - mod_ssl -Self-signet-certificate - Fehler - Seite 2

Hier muss der Aufruf der URL dann noch einmal bestätigt werden, in dem die Schaltfläche [Add Exception…] angeklickt wird und nachfolgendes Dialog-Fenster mit weiteren Informationen, zum präsentiertem Zertifikat, zum Vorschein kommen.

CentOS-7 - Apache - mod_ssl -Self-signet-certificate - Fehler - Bestätigungs-Dialog-Fenster

Durch anklicken der Schaltfläche [Confirm Security Exception] wird bestätigt, das die Seite tatsächlich angezeigt werden soll, und nachfolgende Seite sollte dann abschließend auch angezeigt werden:

CentOS-7 - Apache - mod_ssl -Self-signet-certificate - /server-status

:!: HINWEIS - In vorangestelltem Bild ist zu erkennen, dass der Aufruf der Seite https://www.tachtler.net/server-status auf Port 443 erfolgt ist und damit auch verschlüsselt durchgeführt wurde.

Self-signed-certificate

Nachfolgend soll beschrieben werden, wie ein eigenes Self-signed-certificate einfach erstellt werden kann.

Schlüssel erzeugen

Nachfolgender Befehl erzeugt dazu zuerst einmal einen Schlüssel, wodurch nur mit diesem, das Zertifikat verwendbar wird.

# openssl genrsa -out /etc/pki/tls/private/tachtler.net.key 2048
Generating RSA private key, 2048 bit long modulus
.......................................................+++
.......................................+++
e is 65537 (0x10001)

* Es wird die Datei /etc/pki/tls/private/tachtler.net.key erzeugt!

:!: HINWEIS - Der Schlüssel kann auch eine Passphrase haben, jedoch kann dann kein automatischer Start des Apache HTTP Server mehr erfolgen. Es sei denn, auch die Passphrase ist in einer Datei auf dem Server hinterlegt und diese wird dann beim Starten des Apache HTTP Server eingelesen. Dieses vorgehen ist jedoch nur Sinnvoll, wenn der Apache HTTP Server durch einen Benutzer, ohne - root-Rechte gestartet wird!

CSR erzeugen

Als nächster Schritt wird ein sogenannter „Zertifikatsantrag“ (CSR) generiert. Der Zertifikatsantrag (CSR) enthält den Domainnamen, die e-Mail-Adresse usw. Diese Dateien werden dann an die Zertifizierungsstelle gesendet und von dieser wird dann das Zertifikat ausgestellt. Mit nachfolgendem Befehl wird die Erstellung des Zertifikatsantrags (CSR) durchgeführt:

:!: WICHTIG - Nicht benötigte Angaben werden mit Eingabe eines Punktes [.] übersprungen, es sollte KEIN Passwort verwendet werden!

# openssl req -new -key /etc/pki/tls/private/tachtler.net.key -out /etc/pki/tls/certs/tachtler.net.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 '.', the field will be left blank.
-----
Country Name (2 letter code) [XX]:DE
State or Province Name (full name) []:Bayern (Bavaria)
Locality Name (eg, city) [Default City]:Muenchen (Munich)
Organization Name (eg, company) [Default Company Ltd]:Klaus Tachtler
Organizational Unit Name (eg, section) []:.
Common Name (eg, your name or your server's hostname) []:www.tachtler.net
Email Address []:webmaster@tachtler.net

Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:.

* Es wird die Datei /etc/pki/tls/certs/tachtler.net.csr erzeugt!

Mit folgendem Befehl kann festgestellt werden, ob alle Angaben im Zertifikatsantrag (CSR) korrekt sind:

# openssl req -noout -text -in /etc/pki/tls/certs/tachtler.net.csr 
Certificate Request:
    Data:
        Version: 0 (0x0)
        Subject: C=DE, ST=Bayern (Bavaria), L=Muenchen (Munich), O=Klaus Tachtler, CN=www.tachtler.net/emailAddress=webmaster@tachtler.net
        Subject Public Key Info:
            Public Key Algorithm: rsaEncryption
                Public-Key: (2048 bit)
                Modulus:
                    00:a0:f8:79:f5:ac:11:07:23:a9:6e:17:77:16:40:
                    c3:e8:62:30:b6:21:1b:72:b1:ca:23:85:2d:3a:67:
                    2b:21:6e:ee:96:cc:62:f3:01:a3:17:87:14:c9:98:
                    d8:2e:d6:d6:d4:2b:06:a9:8b:9f:d6:e2:14:80:32:
                    e3:c7:da:af:6c:b7:9d:32:52:20:39:ed:75:0e:fa:
                    3e:12:5a:27:e4:71:b8:51:4f:2a:96:55:8e:f6:e4:
                    8a:07:5b:28:58:ae:4e:17:e7:07:5b:d3:29:30:eb:
                    bd:15:15:ff:78:76:74:d1:2e:ee:5f:bc:a7:fd:1a:
                    b9:dd:e5:a3:3a:27:89:c2:36:30:c0:6b:4d:21:bc:
                    41:8f:ce:61:6e:06:70:07:66:0b:61:f5:91:f6:71:
                    94:3e:c3:7e:1b:5f:ef:06:bf:15:d9:d3:a6:7a:38:
                    76:c6:d7:e4:00:92:08:9d:b2:bc:7a:32:da:57:02:
                    b5:0d:5e:25:73:0b:40:83:e9:03:b9:5c:fa:58:b1:
                    cb:e5:d7:61:7f:12:de:5c:49:b4:d0:5d:bc:8c:b1:
                    62:01:86:5e:6c:43:5c:3d:62:68:a7:1c:bb:f8:1a:
                    8f:9d:6e:ce:2b:d7:36:18:b5:6e:a6:3e:cf:94:72:
                    57:0e:55:7f:c2:dd:43:ab:ea:47:1e:2b:30:1d:97:
                    81:57
                Exponent: 65537 (0x10001)
        Attributes:
            a0:00
    Signature Algorithm: sha256WithRSAEncryption
         48:87:02:ee:8f:f9:7b:17:11:d8:bf:ed:81:c4:1c:e4:3c:ec:
         4d:b7:a9:77:19:5c:92:aa:98:67:23:1c:d1:43:ce:3b:1d:e8:
         21:1d:f2:76:52:0d:25:75:28:38:d6:87:71:34:ce:d9:7c:c0:
         66:b9:d5:ba:08:85:53:61:5a:c2:58:52:02:0a:6e:42:22:61:
         3a:e5:e3:8e:88:f3:68:93:64:b0:ca:fc:69:e7:7a:27:3c:f6:
         89:ee:07:d2:cd:a7:21:5f:bf:38:7c:4e:a2:7e:84:f9:c8:60:
         9a:9c:ce:d0:19:93:22:76:fb:4b:1e:65:a2:8d:ab:b7:8d:ea:
         da:7a:fa:81:a8:88:d3:f8:31:88:b0:ea:90:92:0e:94:54:7c:
         54:26:a7:e9:a3:63:95:a3:e4:00:79:92:fc:f6:e4:3e:82:74:
         55:9d:3d:3a:75:04:5b:77:db:8d:e7:43:b5:b5:bf:fb:e6:60:
         5f:77:ce:a8:1f:a2:d1:65:5a:2d:f5:11:02:51:91:42:03:5d:
         a4:f0:b6:67:05:b7:f8:56:34:8a:84:45:1e:49:c5:19:59:6e:
         87:47:63:ac:88:03:6c:dd:6c:dd:b8:d8:f4:72:57:f6:c8:5f:
         40:62:c7:7e:32:3b:cb:96:88:6d:4e:b9:15:b2:1d:55:be:a1:
         86:c0:0b:94

CRT erzeugen

Zum Abschluß wird mit folgendem Befehl ein Self-Signed-Certificate erstellt, welches für 365 Tage gültig ist:

# openssl x509 -req -days 365 -in /etc/pki/tls/certs/tachtler.net.csr -signkey /etc/pki/tls/private/tachtler.net.key -out /etc/pki/tls/certs/tachtler.net.crt
Signature ok
subject=/C=DE/ST=Bayern (Bavaria)/L=Muenchen (Munich)/O=Klaus Tachtler/CN=www.tachtler.net/emailAddress=webmaster@tachtler.net
Getting Private key

* Es wird die Datei /etc/pki/tls/certs/tachtler.net.crt erzeugt!

Mit folgendem Befehl kann festgestellt werden, ob alle Angaben im Self-Signed-Certificate (CRT) korrekt sind und dies auch korrekt erstellt wurde:

# openssl x509 -noout -text -in /etc/pki/tls/certs/tachtler.net.crt 
Certificate:
    Data:
        Version: 1 (0x0)
        Serial Number: 13350625740743118842 (0xb946f360662e0ffa)
    Signature Algorithm: sha1WithRSAEncryption
        Issuer: C=DE, ST=Bayern (Bavaria), L=Muenchen (Munich), O=Klaus Tachtler, CN=www.tachtler.net/emailAddress=webmaster@tachtler.net
        Validity
            Not Before: Nov 26 10:06:21 2014 GMT
            Not After : Nov 26 10:06:21 2015 GMT
        Subject: C=DE, ST=Bayern (Bavaria), L=Muenchen (Munich), O=Klaus Tachtler, CN=www.tachtler.net/emailAddress=webmaster@tachtler.net
        Subject Public Key Info:
            Public Key Algorithm: rsaEncryption
                Public-Key: (2048 bit)
                Modulus:
                    00:a0:f8:79:f5:ac:11:07:23:a9:6e:17:77:16:40:
                    c3:e8:62:30:b6:21:1b:72:b1:ca:23:85:2d:3a:67:
                    2b:21:6e:ee:96:cc:62:f3:01:a3:17:87:14:c9:98:
                    d8:2e:d6:d6:d4:2b:06:a9:8b:9f:d6:e2:14:80:32:
                    e3:c7:da:af:6c:b7:9d:32:52:20:39:ed:75:0e:fa:
                    3e:12:5a:27:e4:71:b8:51:4f:2a:96:55:8e:f6:e4:
                    8a:07:5b:28:58:ae:4e:17:e7:07:5b:d3:29:30:eb:
                    bd:15:15:ff:78:76:74:d1:2e:ee:5f:bc:a7:fd:1a:
                    b9:dd:e5:a3:3a:27:89:c2:36:30:c0:6b:4d:21:bc:
                    41:8f:ce:61:6e:06:70:07:66:0b:61:f5:91:f6:71:
                    94:3e:c3:7e:1b:5f:ef:06:bf:15:d9:d3:a6:7a:38:
                    76:c6:d7:e4:00:92:08:9d:b2:bc:7a:32:da:57:02:
                    b5:0d:5e:25:73:0b:40:83:e9:03:b9:5c:fa:58:b1:
                    cb:e5:d7:61:7f:12:de:5c:49:b4:d0:5d:bc:8c:b1:
                    62:01:86:5e:6c:43:5c:3d:62:68:a7:1c:bb:f8:1a:
                    8f:9d:6e:ce:2b:d7:36:18:b5:6e:a6:3e:cf:94:72:
                    57:0e:55:7f:c2:dd:43:ab:ea:47:1e:2b:30:1d:97:
                    81:57
                Exponent: 65537 (0x10001)
    Signature Algorithm: sha1WithRSAEncryption
         82:a1:b2:0c:3a:db:f7:38:b0:a2:26:8a:84:b4:70:4c:2c:68:
         dc:13:f3:c2:98:c2:b9:03:91:a1:63:1c:02:4a:ae:3c:3c:e5:
         bb:84:ff:64:f2:22:d4:3a:f7:a8:15:fd:3d:fa:f0:0c:b1:1f:
         91:84:70:31:66:e1:c8:9b:e7:a7:a9:2b:5a:10:66:2e:73:7b:
         74:fd:ad:af:9f:9d:5d:ca:2b:b0:53:13:e2:b1:ab:dd:4b:b3:
         b5:8e:16:90:7d:c9:b2:00:a9:ba:dd:d1:60:99:de:0e:84:48:
         13:ea:00:57:df:72:e5:a3:9a:c5:c8:ab:2b:33:c3:0d:b5:2d:
         28:9e:85:42:9f:40:10:b9:24:29:c5:c0:3f:59:0b:bc:c6:fb:
         c6:17:4d:22:a9:9f:15:9a:d0:04:27:9b:81:45:0a:b2:03:c8:
         85:ae:ad:38:88:2f:24:8d:73:eb:b6:6e:37:7c:44:a8:b4:16:
         e4:7b:9e:7e:03:82:76:87:f4:8b:dc:b1:17:5f:43:4d:98:1e:
         bd:41:f0:6f:bf:07:a3:cf:f9:6b:17:16:65:90:10:a4:46:8d:
         15:a6:7d:9c:00:8c:05:1b:26:53:26:55:de:13:ee:49:68:c5:
         c5:45:d5:60:41:9b:3c:c3:fa:66:2b:a6:59:2d:39:af:2d:6f:
         c5:02:16:42

Dateirechte

Die Installation des gerade erzeugten Self-Signed-Certificate und die Vergabe der richtigen Dateirechte, sind der nächste Schritt zum erfolgreichen Einsatz.

Mit nachfolgenden Befehlen werden die Dateirechte für die Dateien

  • /etc/pki/tls/private/tachtler.net.key und
  • /etc/pki/tls/certs/tachtler.net.crt

noch wie folgt gesetzte werden:

Die Dateirechte für /etc/pki/tls/private/tachtler.net.key, werden mit folgendem Befehl gesetzt:

# chmod 400 /etc/pki/tls/private/tachtler.net.key

Die Dateirechte für /etc/pki/tls/certs/tachtler.net.crt, werden mit folgendem Befehl gesetzt:

# chmod 400 /etc/pki/tls/certs/tachtler.net.crt

CRT einbinden

Anschließend muss nun noch das erzeugte Drittanbieter Zertifikat in den Apache HTTP Server durch anpassen der Konfigurationsdatei

  • /etc/httpd/conf.d/ssl.conf

durch nachfolgend gezeigte Änderungen, bekannt gegeben werden:

(Nur relevanter Ausschnitt')

...
#   Server Certificate:
#   Point SSLCertificateFile at a PEM encoded certificate.  If
#   the certificate is encrypted, then you will be prompted for a
#   pass phrase.  Note that a kill -HUP will prompt again.  A new
#   certificate can be generated using the genkey(1) command.
# Tachtler
# default: SSLCertificateFile /etc/pki/tls/certs/localhost.crt
SSLCertificateFile /etc/pki/tls/certs/tachtler.net.crt
 
#   Server Private Key:
#   If the key is not combined with the certificate, use this
#   directive to point at the key file.  Keep in mind that if
#   you've both a RSA and a DSA private key you can configure
#   both in parallel (to also allow the use of DSA ciphers, etc.)
# Tachtler
# default: SSLCertificateKeyFile /etc/pki/tls/private/localhost.key
SSLCertificateKeyFile /etc/pki/tls/private/tachtler.net.key
...

Neustart

nach den vorangegangenen Konfigurationsschritten, sollte einem Neustart nichts im Wege stehen:

# systemctl restart httpd.service

:!: HINWEIS - Es erfolgen keine weiteren Ausgaben, wenn der Start erfolgreich war !

Überprüfung

In oben gezeigtem Beispiel in der Konfigurationsdatei

  • /etc/httpd/conf.d/ssl.conf

wurde ein eigenes Self-signed-certificate hinterlegt, welches in nachfolgende Konfigurationszeilen konfiguriert wurde:

(nur relevanter Ausschnitt)

...
#   Server Certificate:
#   Point SSLCertificateFile at a PEM encoded certificate.  If
#   the certificate is encrypted, then you will be prompted for a
#   pass phrase.  Note that a kill -HUP will prompt again.  A new
#   certificate can be generated using the genkey(1) command.
# Tachtler
# default: SSLCertificateFile /etc/pki/tls/certs/localhost.crt
SSLCertificateFile /etc/pki/tls/certs/tachtler.net.crt
 
#   Server Private Key:
#   If the key is not combined with the certificate, use this
#   directive to point at the key file.  Keep in mind that if
#   you've both a RSA and a DSA private key you can configure
#   both in parallel (to also allow the use of DSA ciphers, etc.)
# Tachtler
# default: SSLCertificateKeyFile /etc/pki/tls/private/localhost.key
SSLCertificateKeyFile /etc/pki/tls/private/tachtler.net.key
...

Mit nachfolgenden Seitenaufrufen kann überprüft werden, ob die Änderungen durch die Einbindung der zusätzlichen Konfigurationsdateien erfolgreich war:

Der Aufruf der URL:

sollte nachfolgende Anzeige zum Vorschein bringen:

CentOS-7 - Apache - mod_ssl -Self-signet-certificate - Fehler - Seite 1

:!: HINWEIS - Die Fehlermeldung ist normal, da hier ein selbst erstelltes Zertifikat, welches auch noch einen anderen CN (Common Name) als die aufgerufene URL hat, verwendet wird!

Durch anklicken der Fehlermeldung im Bereich [I Understand the Risks], sollte nachfolgende Seite zur Anzeige kommen:

CentOS-7 - Apache - mod_ssl -Self-signet-certificate - Fehler - Seite 2

Hier muss der Aufruf der URL dann noch einmal bestätigt werden, in dem die Schaltfläche [Add Exception…] angeklickt wird und nachfolgendes Dialog-Fenster mit weiteren Informationen, zum präsentiertem Zertifikat, zum Vorschein kommen.

CentOS-7 - Apache - mod_ssl -Self-signet-certificate - Fehler - Bestätigungs-Dialog-Fenster - www.tachtler.net

Durch anklicken der Schaltfläche [View] kann das eigene Self-signed-certificate in einem weiteren Dialog-Fenster zur Anzeige gebracht werden und durch anklicken der Schaltfäche [Close] wieder geschlossen werden:

CentOS-7 - Apache - mod_ssl -Self-signet-certificate - Fehler - Bestätigungs-Dialog-Fenster - www.tachtler.net - Self-signed-certificate - Anzeige

Durch anklicken der Schaltfläche [Confirm Security Exception] wird bestätigt, das die Seite tatsächlich angezeigt werden soll, und nachfolgende Seite sollte dann abschließend auch angezeigt werden:

CentOS-7 - Apache - mod_ssl -Self-signet-certificate - /server-status

:!: HINWEIS - In vorangestelltem Bild ist zu erkennen, dass der Aufruf der Seite https://www.tachtler.net/server-status auf Port 443 erfolgt ist und damit auch verschlüsselt durchgeführt wurde.

Drittanbieter Zertifikate

Zur Einbindung von Zertifikaten von offiziellen Zertifikats Autoritäten, bei denen die sogenannten ROOT-Zertifikate bereits in den Browsern importiert und vorhanden sind, oder wie in nachfolgendem Fall von

in den Browser importiert werden können, sind nachfolgende Schritte notwendig.

Unter diesen Links erhalten Sie mehr Informationen zu

Der Vorteil von CACert gegenüber kostenpflichtigen Zertifikaten von Drittanbietern ist natürlich die kostenlose Bereitstellung von Zertifikaten, auch sogenannten Wildcard-Zertifikaten.

Der Nachteil ist, das die sogenannten ROOT-Zertifikate erst in den entsprechenden Browser manuell importiert werden müssen!

:!: WICHTIG - Eine Registrierung/kostenlose Mitgliedschaft bei CACert ist erforderlich!

ROOT-Zertifikate importieren

Die ROOT-Zertifikate von CACert, können unter nachfolgendem externen Link heruntergeladen und importiert werden:

Nach dem erfolgreichen Importieren der ROOT-Zertifikate, es sollten

  • Klasse 1 PKI Schlüssel
  • Klasse 3 PKI Schlüssel

je nach Betriebssystem und Browser entsprechend importiert werden.

Nachfolgend wird am Browser https://www.mozilla.org/de/firefox/ dargestellt wie die beiden ROOT-Zertifikate importiert werden können.

Ausgehend davon, das die ROOT-Zeritifkate bereits heruntergeladen wurden und hier als Beispiel im Verzeichnis - /tmp gespeichert wurden.

Zuerst wird unter dem Browser https://www.mozilla.org/de/firefox/ der Dialog mit den [Einstellungen] geöffnet und auf den [Reiter: Advanced] und den [Unterreiter: Certificates] gewechselt, wie nachfolgende Bildschirmkopie zeigt:

Browser - Firefox - Zertifikat importieren - Schritt 1

Anschließend sollte dann auf die Schaltfläche [View Certificates] geklickt werden, damit sich nachfolgender Dialog öffnet und der [Reiter: Authorities] ausgewählt sein sollte:

Browser - Firefox - Zertifikat importieren - Schritt 2

Durch anklicken der Schaltfläche [Import], kann dann im sich öffnenden Dialog-Fenster eine Zertifikatsdatei, hier /tmp/root.crt ausgewählt werden:

Browser - Firefox - Zertifikat importieren - Schritt 3

Durch drücken der Schaltfläche [Open] wird dann nachfolgendes Dialog-Fenster angezeigt, in dem der Rahmen festgelegt werden kann, in welchem Umfang dem Zertifikat vertraut wird. Nachfolgend wurden alle Haken entsprechend wie nachfolgend beschrieben gesetzt:

Browser - Firefox - Zertifikat importieren - Schritt 4

Haken Bezeichnung
Trust this CA to identify websites.
Trust this CA to identify email users.
Trust this CA to identify software developers.

Zum Abschluss und zum tatsächlichen Import muss dann die Schaltfläche [OK] angeklickt werden.

:!: WICHTIG - Die ist auch für das zweite Zertifikat - Klasse 3 PKI Schlüssel durchzuführen!

Durch anklicken der Schaltfläche [Import], kann dann im sich öffnenden Dialog-Fenster eine Zertifikatsdatei, hier /tmp/class3.crt ausgewählt werden:

Browser - Firefox - Zertifikat importieren - Schritt 3.1

Durch drücken der Schaltfläche [Open] wird dann nachfolgendes Dialog-Fenster angezeigt, in dem der Rahmen festgelegt werden kann, in welchem Umfang dem Zertifikat vertraut wird. Nachfolgend wurden alle Haken entsprechend wie nachfolgend beschrieben gesetzt:

Browser - Firefox - Zertifikat importieren - Schritt 4.1

Haken Bezeichnung
Trust this CA to identify websites.
Trust this CA to identify email users.
Trust this CA to identify software developers.

Zum Abschluss und zum tatsächlichen Import muss dann die Schaltfläche [OK] angeklickt werden.

Anschließend kann dann in der Liste der importierten Zertifikate überprüft werden ob der jeweilig Importvorgang erfolgreich war und es sollte eine Anzeige wie die nachfolgende zur Anzeige kommen:

Browser - Firefox - Zertifikat importieren - Schritt 5

Schlüssel erzeugen

Nachfolgender Befehl erzeugt dazu zuerst einmal einen Schlüssel, wodurch nur mit diesem, das Zertifikat verwendbar wird.

# openssl genrsa -out /etc/pki/tls/private/tachtler.net.key 2048
Generating RSA private key, 2048 bit long modulus
.......................................................+++
.......................................+++
e is 65537 (0x10001)

* Es wird die Datei /etc/pki/tls/private/tachtler.net.key erzeugt!

:!: HINWEIS - Der Schlüssel kann auch eine Passphrase haben, jedoch kann dann kein automatischer Start des Apache HTTP Server mehr erfolgen. Es sei denn, auch die Passphrase ist in einer Datei auf dem Server hinterlegt und diese wird dann beim Starten des Apache HTTP Server eingelesen. Dieses vorgehen ist jedoch nur Sinnvoll, wenn der Apache HTTP Server durch einen Benutzer, ohne - root-Rechte gestartet wird!

CSR erzeugen

Als nächster Schritt wird ein sogenannter „Zertifikatsantrag“ (CSR) generiert. Der Zertifikatsantrag (CSR) enthält den Domainnamen, die e-Mail-Adresse usw. Diese Dateien werden dann an die Zertifizierungsstelle gesendet und von dieser wird dann das Zertifikat ausgestellt. Mit nachfolgendem Befehl wird die Erstellung des Zertifikatsantrags (CSR) durchgeführt:

:!: WICHTIG - Nicht benötigte Angaben werden mit Eingabe eines Punktes [.] übersprungen, es sollte KEIN Passwort verwendet werden!

# openssl req -new -key /etc/pki/tls/private/tachtler.net.key -out /etc/pki/tls/certs/tachtler.net.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 '.', the field will be left blank.
-----
Country Name (2 letter code) [XX]:DE
State or Province Name (full name) []:Bayern (Bavaria)
Locality Name (eg, city) [Default City]:Muenchen (Munich)
Organization Name (eg, company) [Default Company Ltd]:Klaus Tachtler
Organizational Unit Name (eg, section) []:.
Common Name (eg, your name or your server's hostname) []:*.tachtler.net
Email Address []:webmaster@tachtler.net

Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:.

* Es wird die Datei /etc/pki/tls/certs/tachtler.net.csr erzeugt!

Mit folgendem Befehl kann festgestellt werden, ob alle Angaben im Zertifikatsantrag (CSR) korrekt sind:

# openssl req -noout -text -in /etc/pki/tls/certs/tachtler.net.csr 
Certificate Request:
    Data:
        Version: 0 (0x0)
        Subject: C=DE, ST=Bayern (Bavaria), L=Muenchen (Munich), O=Klaus Tachtler, CN=*.tachtler.net/emailAddress=webmaster@tachtler.net
        Subject Public Key Info:
            Public Key Algorithm: rsaEncryption
                Public-Key: (2048 bit)
                Modulus:
                    00:a0:f8:79:f5:ac:11:07:23:a9:6e:17:77:16:40:
                    c3:e8:62:30:b6:21:1b:72:b1:ca:23:85:2d:3a:67:
                    2b:21:6e:ee:96:cc:62:f3:01:a3:17:87:14:c9:98:
                    d8:2e:d6:d6:d4:2b:06:a9:8b:9f:d6:e2:14:80:32:
                    e3:c7:da:af:6c:b7:9d:32:52:20:39:ed:75:0e:fa:
                    3e:12:5a:27:e4:71:b8:51:4f:2a:96:55:8e:f6:e4:
                    8a:07:5b:28:58:ae:4e:17:e7:07:5b:d3:29:30:eb:
                    bd:15:15:ff:78:76:74:d1:2e:ee:5f:bc:a7:fd:1a:
                    b9:dd:e5:a3:3a:27:89:c2:36:30:c0:6b:4d:21:bc:
                    41:8f:ce:61:6e:06:70:07:66:0b:61:f5:91:f6:71:
                    94:3e:c3:7e:1b:5f:ef:06:bf:15:d9:d3:a6:7a:38:
                    76:c6:d7:e4:00:92:08:9d:b2:bc:7a:32:da:57:02:
                    b5:0d:5e:25:73:0b:40:83:e9:03:b9:5c:fa:58:b1:
                    cb:e5:d7:61:7f:12:de:5c:49:b4:d0:5d:bc:8c:b1:
                    62:01:86:5e:6c:43:5c:3d:62:68:a7:1c:bb:f8:1a:
                    8f:9d:6e:ce:2b:d7:36:18:b5:6e:a6:3e:cf:94:72:
                    57:0e:55:7f:c2:dd:43:ab:ea:47:1e:2b:30:1d:97:
                    81:57
                Exponent: 65537 (0x10001)
        Attributes:
            a0:00
    Signature Algorithm: sha256WithRSAEncryption
         48:87:02:ee:8f:f9:7b:17:11:d8:bf:ed:81:c4:1c:e4:3c:ec:
         4d:b7:a9:77:19:5c:92:aa:98:67:23:1c:d1:43:ce:3b:1d:e8:
         21:1d:f2:76:52:0d:25:75:28:38:d6:87:71:34:ce:d9:7c:c0:
         66:b9:d5:ba:08:85:53:61:5a:c2:58:52:02:0a:6e:42:22:61:
         3a:e5:e3:8e:88:f3:68:93:64:b0:ca:fc:69:e7:7a:27:3c:f6:
         89:ee:07:d2:cd:a7:21:5f:bf:38:7c:4e:a2:7e:84:f9:c8:60:
         9a:9c:ce:d0:19:93:22:76:fb:4b:1e:65:a2:8d:ab:b7:8d:ea:
         da:7a:fa:81:a8:88:d3:f8:31:88:b0:ea:90:92:0e:94:54:7c:
         54:26:a7:e9:a3:63:95:a3:e4:00:79:92:fc:f6:e4:3e:82:74:
         55:9d:3d:3a:75:04:5b:77:db:8d:e7:43:b5:b5:bf:fb:e6:60:
         5f:77:ce:a8:1f:a2:d1:65:5a:2d:f5:11:02:51:91:42:03:5d:
         a4:f0:b6:67:05:b7:f8:56:34:8a:84:45:1e:49:c5:19:59:6e:
         87:47:63:ac:88:03:6c:dd:6c:dd:b8:d8:f4:72:57:f6:c8:5f:
         40:62:c7:7e:32:3b:cb:96:88:6d:4e:b9:15:b2:1d:55:be:a1:
         86:c0:0b:94

CRT erzeugen

:!: WICHTIG - Das Zertifikat wird nun durch Hochladen des Zertifikatsantrag (CSR) auf die Homepage von CACert erzeugt und kann dort entsprechen dann heruntergeladen werden!

Mit folgendem Befehl kann festgestellt werden, ob alle Angaben im Drittanbieter Zertifikats (CRT) korrekt sind und dies auch korrekt erstellt wurde:

# openssl x509 -noout -text -in /etc/pki/tls/certs/tachtler.net.crt 
Certificate:
    Data:
        Version: 3 (0x2)
        Serial Number: 142727 (0x22d87)
    Signature Algorithm: sha512WithRSAEncryption
        Issuer: O=CAcert Inc., OU=http://www.CAcert.org, CN=CAcert Class 3 Root
        Validity
            Not Before: Apr 10 18:52:29 2014 GMT
            Not After : Apr  9 18:52:29 2016 GMT
        Subject: CN=*.tachtler.net
        Subject Public Key Info:
            Public Key Algorithm: rsaEncryption
                Public-Key: (2048 bit)
                Modulus:
                    00:f2:29:af:e1:4c:88:b5:e5:1c:3f:b3:ea:7f:d4:
                    73:41:91:55:9b:37:1d:c6:0a:a6:3e:29:b9:85:a9:
                    8b:fb:e0:91:9c:c9:33:bf:98:06:02:fc:a9:74:9e:
                    a0:01:91:5e:db:73:93:db:34:2d:d8:dc:94:b8:c5:
                    f7:de:59:28:ab:20:72:95:5f:59:d1:79:18:7f:7b:
                    c3:30:98:65:2b:50:47:5f:4f:5a:d4:97:6a:e2:95:
                    cd:3b:d6:0b:c2:a1:d9:96:64:6a:7a:ff:d2:de:cc:
                    b6:a0:5d:25:dc:57:1c:98:59:22:e0:38:43:d8:e2:
                    49:65:60:83:3c:7f:5e:80:1b:c5:d2:4d:64:79:d9:
                    b3:21:b7:7e:9b:64:c1:71:4a:fe:7c:a3:13:20:4b:
                    f9:9e:e4:60:e6:d7:71:43:fb:a6:c8:77:11:9c:e7:
                    d5:b9:fa:a2:cb:3d:e6:8c:ab:2d:0c:ae:6f:34:61:
                    24:0a:c4:a3:d2:68:b2:ab:72:87:57:00:82:7b:e8:
                    7a:c3:d0:95:b0:3e:07:1b:49:f4:ba:0e:f7:80:5f:
                    2b:01:70:f4:cc:39:1a:76:e1:c1:b8:f1:b2:0a:ee:
                    ba:1f:8c:97:c0:99:c8:57:db:17:d1:ec:59:1b:91:
                    6b:5b:32:47:12:04:cc:0f:94:d3:52:e9:de:9d:3f:
                    ba:15
                Exponent: 65537 (0x10001)
        X509v3 extensions:
            X509v3 Basic Constraints: critical
                CA:FALSE
            X509v3 Key Usage: critical
                Digital Signature, Key Encipherment, Key Agreement
            X509v3 Extended Key Usage: 
                TLS Web Client Authentication, TLS Web Server Authentication, Netscape Server Gated Crypto, Microsoft Server Gated Crypto
            Authority Information Access: 
                OCSP - URI:http://ocsp.cacert.org/

            X509v3 CRL Distribution Points: 

                Full Name:
                  URI:http://crl.cacert.org/class3-revoke.crl

            X509v3 Subject Alternative Name: 
                DNS:*.tachtler.net, othername:<unsupported>
    Signature Algorithm: sha512WithRSAEncryption
         66:a2:6d:30:e0:fb:39:51:1b:e9:56:21:1b:ac:bc:5c:42:a0:
         f7:38:2b:bf:0f:a3:0f:20:03:e9:e8:5a:80:0f:52:11:20:b0:
         17:27:c0:b0:56:03:7b:fd:b2:72:51:2a:b2:67:40:68:19:51:
         5d:8e:ba:a4:86:7d:f3:2f:f7:be:66:50:53:5f:93:67:c4:ca:
         e9:7a:0e:92:ef:53:2f:58:19:13:f0:0e:10:b7:6f:32:51:62:
         86:d8:27:ce:3f:66:49:a6:9c:11:68:26:bc:ea:18:f4:42:dd:
         0c:da:4a:41:f1:e9:24:11:29:38:97:15:bd:8a:5b:a0:5b:76:
         f8:b0:74:c6:54:82:6f:3f:3e:f5:90:a9:94:e4:d7:fd:ac:03:
         df:de:4e:30:5b:83:14:b3:68:6e:09:6b:0c:9c:17:a4:3f:78:
         01:97:d3:45:43:76:8c:e8:57:57:61:14:7b:ec:b2:8d:55:55:
         af:65:a1:18:cd:3b:a4:86:9f:1e:16:21:41:a9:57:cc:b2:08:
         63:8d:7a:3b:f3:6d:09:f3:a5:f6:50:93:b7:3a:23:0f:27:95:
         76:ab:72:78:13:1c:0c:e6:cf:28:2a:ce:33:2e:dd:c1:0a:05:
         d8:48:9f:72:27:82:38:34:bf:ec:20:a2:85:53:b3:fd:c2:15:
         ea:3f:66:08:be:88:77:f1:db:94:04:27:53:31:a7:62:65:00:
         7c:b8:de:ef:db:7a:3c:0f:c1:54:e3:a0:d9:31:36:ee:b0:ea:
         b2:60:f1:7e:3e:be:0d:b8:e2:47:c5:91:aa:ec:e6:06:07:5a:
         a6:9e:48:fe:6b:bb:28:1e:dc:87:8b:e7:50:9b:cc:b0:0b:b9:
         ca:f4:35:ef:cb:32:05:46:da:76:14:72:de:5b:25:76:97:13:
         83:06:a3:30:2c:9e:bf:6f:bb:72:c4:4a:77:22:85:93:d9:7e:
         14:fc:6d:bb:47:eb:1a:6e:82:48:ab:31:2f:ee:fb:dc:f3:7b:
         0d:3a:28:60:6d:b8:e7:58:4d:06:74:2f:93:f4:8a:b7:90:1b:
         92:73:10:b7:71:55:b6:a9:88:13:89:fb:cd:e9:eb:7a:12:2d:
         49:9a:1c:31:d7:77:14:70:3a:2b:a3:8a:91:67:83:bf:53:ba:
         a8:bd:1b:81:56:3b:61:bf:29:0a:7d:be:fc:ed:a3:bb:1d:f3:
         b9:9c:1e:1d:ce:b3:16:17:e0:f0:87:d3:2f:a3:0e:95:f6:52:
         5a:53:14:fa:ae:39:da:f2:17:9e:82:d5:21:6c:8b:82:62:c6:
         71:9c:95:81:76:ae:98:25:57:a2:93:2f:d4:bf:79:be:bb:8c:
         69:64:e5:5d:c1:95:61:08

CRT einbinden

Abschließend muss nun noch das erzeugte Drittanbieter Zertifikats in den Apache HTTP Server durch anpassen der Konfigurationsdatei

  • /etc/httpd/conf.d/ssl.conf

durch nachfolgend gezeigte Änderungen und Ergänzungen, bekannt gegeben werden:

(Nur relevanter Ausschnitt')

...
#   Server Certificate:
#   Point SSLCertificateFile at a PEM encoded certificate.  If
#   the certificate is encrypted, then you will be prompted for a
#   pass phrase.  Note that a kill -HUP will prompt again.  A new
#   certificate can be generated using the genkey(1) command.
# Tachtler
# default: SSLCertificateFile /etc/pki/tls/certs/localhost.crt
SSLCertificateFile /etc/pki/tls/certs/tachtler.net.crt
 
#   Server Private Key:
#   If the key is not combined with the certificate, use this
#   directive to point at the key file.  Keep in mind that if
#   you've both a RSA and a DSA private key you can configure
#   both in parallel (to also allow the use of DSA ciphers, etc.)
# Tachtler
# default: SSLCertificateKeyFile /etc/pki/tls/private/localhost.key
SSLCertificateKeyFile /etc/pki/tls/private/tachtler.net.key
...

ROOT-CRT einbinden

Die ROOT-Zertifikate

  • Klasse 1 PKI Schlüssel
  • Klasse 3 PKI Schlüssel

in einer Datei, mit Namen CAcert_chain.pem-Zertifikate können unter folgender Adresse heruntergeladen werden:

Abschließend muss nun noch eine Datei mit den ROOT-Zeritifikaten in den Apache HTTP Server durch anpassen der Konfigurationsdatei

  • /etc/httpd/conf.d/ssl.conf

durch nachfolgend gezeigte Änderungen, bekannt gegeben werden:

(Nur relevanter Ausschnitt')

#   Server Certificate Chain:
#   Point SSLCertificateChainFile at a file containing the
#   concatenation of PEM encoded CA certificates which form the
#   certificate chain for the server certificate. Alternatively
#   the referenced file can be the same as SSLCertificateFile
#   when the CA certificates are directly appended to the server
#   certificate for convinience.
# Tachtler
# default: #SSLCertificateChainFile /etc/pki/tls/certs/server-chain.crt
SSLCertificateChainFile /etc/pki/tls/certs/CAcert_chain.pem
...

Dateirechte

Die Installation des gerade erzeugten Drittanbieter Zertifikats und die Vergabe der richtigen Dateirechte, sind der nächste Schritt zum erfolgreichen Einsatz.

Mit nachfolgenden Befehlen werden die Dateirechte für die Dateien

  • /etc/pki/tls/private/tachtler.net.key,
  • /etc/pki/tls/certs/tachtler.net.crt und
  • /etc/pki/tls/certs/CAcert_chain.pem

noch wie folgt gesetzte werden:

Die Dateirechte für /etc/pki/tls/private/tachtler.net.key, werden mit folgendem Befehl gesetzt:

# chmod 400 /etc/pki/tls/private/tachtler.net.key

Die Dateirechte für /etc/pki/tls/certs/tachtler.net.crt, werden mit folgendem Befehl gesetzt:

# chmod 400 /etc/pki/tls/certs/tachtler.net.crt

Die Dateirechte für /etc/pki/tls/certs/CAcert_chain.pem, werden mit folgendem Befehl gesetzt:

# chmod 400 /etc/pki/tls/certs/CAcert_chain.pem

Neustart

nach den vorangegangenen Konfigurationsschritten, sollte einem Neustart nichts im Wege stehen:

# systemctl restart httpd.service

:!: HINWEIS - Es erfolgen keine weiteren Ausgaben, wenn der Start erfolgreich war !

Überprüfung

In oben gezeigtem Beispiel in der Konfigurationsdatei

  • /etc/httpd/conf.d/ssl.conf

wurde ein Drittanbieter Zertifikat hinterlegt, welches in nachfolgende Konfigurationszeilen konfiguriert wurde:

(nur relevanter Ausschnitt)

...
#   Server Certificate:
#   Point SSLCertificateFile at a PEM encoded certificate.  If
#   the certificate is encrypted, then you will be prompted for a
#   pass phrase.  Note that a kill -HUP will prompt again.  A new
#   certificate can be generated using the genkey(1) command.
# Tachtler
# default: SSLCertificateFile /etc/pki/tls/certs/localhost.crt
SSLCertificateFile /etc/pki/tls/certs/tachtler.net.crt
 
#   Server Private Key:
#   If the key is not combined with the certificate, use this
#   directive to point at the key file.  Keep in mind that if
#   you've both a RSA and a DSA private key you can configure
#   both in parallel (to also allow the use of DSA ciphers, etc.)
# Tachtler
# default: SSLCertificateKeyFile /etc/pki/tls/private/localhost.key
SSLCertificateKeyFile /etc/pki/tls/private/tachtler.net.key
 
#   Server Certificate Chain:
#   Point SSLCertificateChainFile at a file containing the
#   concatenation of PEM encoded CA certificates which form the
#   certificate chain for the server certificate. Alternatively
#   the referenced file can be the same as SSLCertificateFile
#   when the CA certificates are directly appended to the server
#   certificate for convinience.
# Tachtler
# default: #SSLCertificateChainFile /etc/pki/tls/certs/server-chain.crt
SSLCertificateChainFile /etc/pki/tls/certs/CAcert_chain.pem
...

Mit nachfolgenden Seitenaufrufen kann überprüft werden, ob die Änderungen durch die Einbindung der zusätzlichen Konfigurationsdateien erfolgreich war:

Der Aufruf der URL:

sollte nachfolgende Anzeige zum Vorschein bringen:

CentOS-7 - Apache - mod_ssl -Self-signet-certificate - /server-status

:!: HINWEIS - In vorangestelltem Bild ist zu erkennen, dass der Aufruf der Seite https://www.tachtler.net/server-status auf Port 443 erfolgt ist und damit auch verschlüsselt durchgeführt wurde.

Diese Website verwendet Cookies. Durch die Nutzung der Website stimmen Sie dem Speichern von Cookies auf Ihrem Computer zu. Außerdem bestätigen Sie, dass Sie unsere Datenschutzbestimmungen gelesen und verstanden haben. Wenn Sie nicht einverstanden sind, verlassen Sie die Website.Weitere Information
tachtler/apache_http_server_centos_7_-_mod_ssl_-_verschluesselung_https.1417016945.txt.gz · Zuletzt geändert: 2014/11/26 16:49 von klaus