Por lo general, los paquetes Apache o mod_ssl vienen con secuencias de comandos de muestra para generar solicitudes de certificados para enviar a un proveedor de PKI.
Sin embargo, proporcionamos a continuación un script de muestra que utiliza OpenSSL para generar una solicitud de certificado para usar en Apache.
#!/bin/sh
#
# Generate server certificate request
#
# Generate 1024 bits RSA key, store private key in a
# no password protected PEM file server.key, store certificate
# request in a PEM file server.csr, using system default
# configuration file
#
# The produced key will be valid for 1825 days (5 years)
#
echo
echo Generating server private key and certificate request...
echo
openssl req -newkey rsa:1024 -outform PEM -out server.csr -keyout server.key -keyform PEM \
-days 1825 -nodes
Este script genera una clave privada RSA en el archivo “server.key” y una solicitud de certificado en el archivo “server.csr”.
Primero, inicie este script usando el comando:
sh apache_request_cert.sh
Generará una clave privada y le pedirá las propiedades de solicitud de certificado:
- Código de país, generalmente requerido
- Nombre del estado o provincia, generalmente requerido
- Ciudad, generalmente requerida
- Nombre de la organización o empresa, generalmente requerido
- Nombre de la unidad organizativa, normalmente opcional
- Nombre común (este es el nombre DNS o la dirección IP de su servidor), obligatorio
- Una dirección de correo electrónico, necesaria para recibir el certificado generado por la autoridad de certificación.
- Una contraseña de desafío opcional
- Un nombre de empresa opcional
En nuestra muestra, hemos generado una solicitud de certificado para nuestro nombre de servidor “ocs.domain.tld”.
A continuación, debe transmitir su solicitud de certificado “server.csr” a su Autoridad de Certificación PKI.
Una vez que haya recibido su certificado de servidor de la Autoridad de certificación, solo tiene que copiar el archivo de certificado del servidor “server.crt” y los archivos de clave privada del servidor “server.key” en los directorios apropiados, y actualizar los archivos de configuración de Apache/mod_ssl para usar estos archivos.
También debe recuperar el certificado raíz de la autoridad de certificación en el archivo “ca_root.crt” para especificarlo en la configuración de Apache.
Aquí hay una configuración minimalista de Apache/mod_ssl de muestra para usar SSL en CentOS/Fedora/RedHat Linux. (el certificado del servidor se almacena en el directorio “/etc/httpd/conf/ssl.crt” y la clave del servidor se almacena en el directorio “/etc/httpd/conf/ssl.key”).
Nota: Generalmente, Apache para Win32 viene con un archivo de configuración Apache / mod_ssl predefinido. Entonces,
¡No use la siguiente configuración si su sistema ya tiene un archivo de configuración para mod_ssl!configuración para mod_ssl!
#
# This is the Apache server configuration file providing SSL support.
# It contains the configuration directives to instruct the server how to
# serve pages over an https connection. For detailing information about these
# directives see <URL:http://httpd.apache.org/docs-2.0/mod/mod_ssl.html>
#
# For the moment, see <URL:http://www.modssl.org/docs/> for this info.
# The documents are still being prepared from material donated by the
# modssl project.
#
# Do NOT simply read the instructions in here without understanding
# what they do. They're here only as hints or reminders. If you are unsure
# consult the online docs. You have been warned.
#
LoadModule ssl_module modules/mod_ssl.so
# Until documentation is completed, please check http://www.modssl.org/
# for additional config examples and module docmentation. Directives
# and features of mod_ssl are largely unchanged from the mod_ssl project
# for Apache 1.3.
#
# When we also provide SSL we have to listen to the
# standard HTTP port (see above) and to the HTTPS port
#
# To allow connections to IPv6 addresses add "Listen [::]:443"
#
Listen 0.0.0.0:443
#
# Some MIME-types for downloading Certificates and CRLs
#
AddType application/x-x509-ca-cert .crt
AddType application/x-pkcs7-crl .crl
# 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 builtin
##
## SSL Virtual Host Context
##
<VirtualHost _default_:443>
# Use separate log files:
ErrorLog logs/ssl_error_log
TransferLog logs/ssl_access_log
# SSL Engine Switch:
# Enable/Disable SSL for this virtual host.
SSLEngine on
# SSL Cipher Suite:
# List the ciphers that the client is permitted to negotiate.
# See the mod_ssl documentation for a complete list.
SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP
# 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 test
# certificate can be generated with `make certificate' under
# built time. Keep in mind that if you've both a RSA and a DSA
# certificate you can configure both in parallel (to also allow
# the use of DSA ciphers, etc.)
SSLCertificateFile /etc/httpd/conf/ssl.crt/server.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/httpd/conf/ssl.key/server.key
# 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)
# Note: Inside SSLCACertificatePath you need hash symlinks
# to point to the certificate files. Use the provided
# Makefile to update the hash symlinks after changes.
#SSLCACertificatePath /etc/httpd/conf/ssl.crt
SSLCACertificateFile /usr/share/ssl/certs/ca_root.crt
# SSL Engine Options:
# 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.
SSLOptions +StdEnvVars
# 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.
SetEnvIf User-Agent ".*MSIE.*" 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>
Una vez que haya configurado su servidor web Apache, no olvide reiniciar el demonio Apache para que los cambios surtan efecto.
Por último, debe instalar el archivo de certificado raíz de la autoridad de certificación “ca_root.crt” en cada computadora cliente en el directorio de instalación del Agente de inventario de OCS, bajo el nombre “cacert.pem”.