9.1.12.2 Con el servidor OCS Inventory para Linux

Por lo general, los paquetes Apache o mod_ssl vienen con scripts de muestra para generar certificados, especialmente certificados de prueba.

 

Sin embargo, proporcionamos a continuación un script de muestra que usa OpenSSL para generar un certificado autofirmado para usar en Apache.

 

#!/bin/sh
#
# First, generate apache server certificate request
#
# Generate 1024 bits RSA key, store private key in a
# no password protected PEM file server.key, using
# system default openssl configuration file.
#
echo
echo Generating Apache server private key...
echo
openssl genrsa -out server.key 1024
#
# Next, sign the apache server certificate with the apache
# server key
#
# Sign with PEM certificate server.crt, using PEM file
# server.key for server private key, using system default
# openssl configuration file.
#
# The produced certificate will be valid for 1825 days (about 5 years)
#
echo
echo Generating Apache server self signed certificate...
echo
openssl req -outform PEM -new -key server.key -x509 -days 1825 -out server.crt

Este script genera una clave privada RSA en el archivo “server.key” y un certificado autofirmado X.509 en el archivo “server.crt”.

 

Primero, inicie este script usando el comando:

 

sh apache_generate_cert.sh

Generará una clave privada y le pedirá las propiedades del 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, generalmente opcional

 

En nuestra muestra, hemos generado un certificado autofirmado para nuestro nombre de servidor “ocs.domain.tld”.

 

A continuació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.

 

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, la configuración de Apache/mod_ssl se proporciona para su sistema. Por lo tanto, no use la siguiente configuración si su sistema ya tiene un archivo de 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

# 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 del servidor “server.crt” en cada computadora cliente en el directorio de instalación del Agente de inventario de OCS, bajo el nombre “cacert.pem”.

 

Para Debian 9 Stretch:

 

apt install ssl-cert
a2ensite default-ssl
a2enmod ssl
make-ssl-cert generate-default-snakeoil --force-owerwrite
systemctl restart apache2

copiar /etc/ssl/certs/ssl-cert-snakeoil.pem en cacert.pem y distribuir

 

Para Fedora/RedHat/Centos 7:

 

El comando openssl crea un certificado público y una clave privada.

 

openssl genrsa -out server.key 2048
openssl req -new -key server.key -out server.csr

Autofirmar el certificado

 

openssl x509 -req -days 3650 -in server.csr -signkey server.key -out server.crt

Configurar el certificado

 

Coloque estos 2 archivos en el directorio de certificados

 

cp server.crt /etc/ssl/certs/
cp server.key /etc/ssl/private/

Establezca los valores correctos en /etc/httpd/conf.d/ssl.conf.

 

Ir al contenido