EasyRSA es una herramienta de código abierto que simplifica el proceso de gestión de Infraestructura de Clave Pública (PKI) para el cifrado y las firmas digitales. Dicho de forma más simple: genera certificados y los almacena adecuadamente. Para ello, se basa en el algoritmo RSA, que es un algoritmo de criptografía de clave pública ampliamente utilizado.
Está diseñado para facilitar la configuración de un sistema PKI a pequeña escala, por ejemplo, para uso personal o de pequeñas empresas. Proporciona una interfaz de línea de comandos simple para crear, administrar y revocar certificados digitales, que se utilizan para autenticar la identidad de usuarios o dispositivos en una red.
Uno de los principales beneficios de utilizar EasyRSA es que elimina la necesidad de generar y gestionar manualmente claves y certificados criptográficos, que puede ser un proceso complejo y propenso a errores. Con EasyRSA, puede crear y administrar certificados con solo unos pocos comandos simples, por lo que es una gran opción para los usuarios que quieran implementar PKI sin necesidad de amplios conocimientos técnicos o experiencia.
EasyRSA es desarrollado y mantenido por OpenVPN, compartiendo el código fuente en Github, por lo que podemos confiar plenamente en este proyecto ya que es auditado por la comunidad. Además es posible colaborar en su desarrollo, ya que admiten PRs (pull requests) con contribuciones de código, informes de errores y solicitudes de características. Este enfoque colaborativo es crucial para asegurar que EasyRSA sea una herramienta referente para los usuarios que gestionan PKIs.
EasyRSA se puede descargar desde el repositorio de Github, en la sección releases, y también podemos obtener el código completo (git pull https://github.com/OpenVPN/easy-rsa.git
). Las instrucciones de instalación variarán dependiendo del sistema operativo y configuración, pero normalmente implican descargar el código fuente, extrayéndolo a una carpeta y ejecutando el script. En este ejemplo usaré la versión para Linux, con extensión .tgz.
$ curl -L https://github.com/OpenVPN/easy-rsa/releases/download/v3.1.2/EasyRSA-3.1.2.tgz -o EasyRSA-3.1.2.tgz
$ tar -xzf EasyRSA-3.1.2.tgz
$ cd EasyRSA-3.1.2/
$ ll
total 212
-rw-rw-r--. 1 vagrant vagrant 8046 Jan 13 21:49 ChangeLog
-rw-rw-r--. 1 vagrant vagrant 1305 Jan 13 21:49 COPYING.md
drwxrwxr-x. 2 vagrant vagrant 197 Jan 13 21:49 doc
-rwxrwxr-x. 1 vagrant vagrant 148532 Jan 13 21:49 easyrsa
-rw-rw-r--. 1 vagrant vagrant 18092 Jan 13 21:49 gpl-2.0.txt
-rw-rw-r--. 1 vagrant vagrant 1036 Jan 13 21:49 mktemp.txt
-rw-rw-r--. 1 vagrant vagrant 5043 Jan 13 21:49 openssl-easyrsa.cnf
-rw-rw-r--. 1 vagrant vagrant 2269 Jan 13 21:49 README.md
-rw-rw-r--. 1 vagrant vagrant 3335 Jan 13 21:49 README.quickstart.md
-rw-rw-r--. 1 vagrant vagrant 9014 Jan 13 21:49 vars.example
drwxrwxr-x. 2 vagrant vagrant 122 Feb 26 12:40 x509-types
$ ./easyrsa -h
Easy-RSA 3 usage and overview
USAGE: easyrsa [options] COMMAND [command-options]
A list of commands is shown below. To get detailed usage and help for a
command, run:
./easyrsa help COMMAND
For a listing of options that can be supplied before the command, use:
./easyrsa help options
Here is the list of commands available with a short syntax reminder. Use the
'help' command above to get full usage details.
init-pki [ cmd-opts ]
build-ca [ cmd-opts ]
gen-dh
gen-req <file_name_base> [ cmd-opts ]
sign-req <type> <file_name_base>
build-client-full <file_name_base> [ cmd-opts ]
build-server-full <file_name_base> [ cmd-opts ]
build-serverClient-full <file_name_base> [ cmd-opts ]
revoke <file_name_base> [ cmd-opts ]
renew <file_name_base>
revoke-renewed <file_name_base> [ cmd-opts ]
rewind-renew <certificate_serial_number>
rebuild <file_name_base> [ cmd-opts ]
gen-crl
update-db
make-safe-ssl
show-req <file_name_base> [ cmd-opts ]
show-cert <file_name_base> [ cmd-opts ]
show-ca [ cmd-opts ]
show-crl
show-expire <file_name_base> (Optional)
show-revoke <file_name_base> (Optional)
show-renew <file_name_base> (Optional)
verify <file_name_base>
import-req <request_file_path> <short_name_base>
export-p1 <file_name_base> [ cmd-opts ]
export-p7 <file_name_base> [ cmd-opts ]
export-p8 <file_name_base> [ cmd-opts ]
export-p12 <file_name_base> [ cmd-opts ]
set-pass <file_name_base> [ cmd-opts ]
upgrade <type>
DIRECTORY STATUS (commands would take effect on these locations)
EASYRSA: /home/vagrant/EasyRSA-3.1.2
PKI: /home/vagrant/EasyRSA-3.1.2/pki
x509-types: /home/vagrant/EasyRSA-3.1.2/x509-types
Como se puede ver en las últimas 3 líneas, donde se muestra DIRECTORY STATUS, los directorios que se van a usar son por defecto. Esto nos puede ocasionar problemas si queremos crear un PKI en otro directorio o si queremos gestionar múltiples PKIs, ya que apuntarán a directorios incorrectos, creando PKIs corrompidos desde el primer momento. Es por ello que os recomiendo “instalar” manualmente la aplicación, añadiendo un alias con los parámetros necesarios, como os muestro a continuación.
Suponemos que nuestras aplicaciones de “instalación manual” las tenemos todas en ~/apps
.
$ cd ~
$ ll
total 68
drwxrwxr-x. 2 vagrant vagrant 6 Feb 26 12:55 apps
drwxrwxr-x. 4 vagrant vagrant 214 Jan 13 21:49 EasyRSA-3.1.2
-rw-rw-r--. 1 vagrant vagrant 68984 Feb 26 12:39 EasyRSA-3.1.2.tgz
$ mv EasyRSA-3.1.2 apps/
Ahora podemos ejecutar la aplicación de la siguiente forma:
$ EASYRSA=/home/vagrant/apps/EasyRSA-3.1.2 EASYRSA_PKI=pki /home/vagrant/apps/EasyRSA-3.1.2/easyrsa --help
...
DIRECTORY STATUS (commands would take effect on these locations)
EASYRSA: /home/vagrant/apps/EasyRSA-3.1.2
PKI: pki
x509-types: /home/vagrant/apps/EasyRSA-3.1.2/x509-types
Como se puede ver en DIRECTORY STATUS, las configuraciones EASYRSA
y x509-types
ya apuntan a los directorios donde se encuentran realmente. La configuración PKI
apuntará al directorio en el que nos encontremos.
Si creamos un alias será más cómodo su uso:
alias easyrsa='EASYRSA=/home/vagrant/apps/EasyRSA-3.1.2 EASYRSA_PKI=pki /home/vagrant/apps/EasyRSA-3.1.2/easyrsa'
Este podemos añadirlo en ~/.bashrc
para que lo tengamos siempre disponible.
Y ya se puede usar cómodamente:
$ easyrsa
...
DIRECTORY STATUS (commands would take effect on these locations)
EASYRSA: /home/vagrant/apps/EasyRSA-3.1.2
PKI: pki
x509-types: /home/vagrant/apps/EasyRSA-3.1.2/x509-types
Vamos a crear un PKI simple, que bastará para la mayoría de los casos de uso, como por ejemplo un servidor web. Vamos a emitir una CA raíz y un CERT servidor sin contraseña.
Se puede crear un nuevo PKI ejecutando el comando init-pki
. Esto creará un nuevo directorio PKI con los archivos y carpetas necesarios para gestionar sus certificados y llaves.
$ cd ~
$ mkdir -p almacenes/ej1
$ cd almacenes/ej1
$ easyrsa init-pki
Notice
------
'init-pki' complete; you may now create a CA or requests.
Your newly created PKI dir is:
* pki
* Using Easy-RSA configuration:
* IMPORTANT: Easy-RSA 'vars' template file has been created in your new PKI.
Edit this 'vars' file to customise the settings for your PKI.
To use a global vars file, use global option --vars=<YOUR_VARS>
* Using x509-types directory: /home/vagrant/apps/EasyRSA-3.1.2/x509-types
Ya tenemos el PKI generado en ej1/pki/
.
El segundo paso en la creación de nuestro PKI es generar una CA raíz, para lo que generaremos una clave y un certificado. Usaremos el comando easyrsa build-ca
, que nos guiará, con un formulario interactivo (wizard), para introducir la información requerida. Por defecto solo nos pedirá el Common Name, porque así se establece en el archivo de vars. Para introducir más información en los certificados será necesario modificar dicho archivo, pero lo veremos más adelante.
$ easyrsa build-ca
* Using SSL: openssl OpenSSL 1.1.1k FIPS 25 Mar 2021
* Using Easy-RSA configuration: pki/vars
Enter New CA Key Passphrase:
Confirm New CA Key Passphrase:
................................+++++
...........................................................+++++
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.
-----
Common Name (eg: your user, host, or server name) [Easy-RSA CA]:infraestructurasbigdatacloud CA
Notice
------
CA creation complete and you may now import and sign cert requests.
Your new CA certificate file for publishing is at:
pki/ca.crt
Y ya tenemos nuestra CA raíz generada:
$ ll pki
total 40
-rw-------. 1 vagrant vagrant 1285 Feb 26 13:43 ca.crt <---------------------
drwx------. 2 vagrant vagrant 6 Feb 26 13:42 certs_by_serial
-rw-------. 1 vagrant vagrant 0 Feb 26 13:42 index.txt
-rw-------. 1 vagrant vagrant 0 Feb 26 13:42 index.txt.attr
drwx------. 2 vagrant vagrant 6 Feb 26 13:42 inline
drwx------. 2 vagrant vagrant 6 Feb 26 13:42 issued
-rw-------. 1 vagrant vagrant 5043 Feb 26 13:30 openssl-easyrsa.cnf
drwx------. 2 vagrant vagrant 20 Feb 26 13:43 private
drwx------. 2 vagrant vagrant 6 Feb 26 13:30 reqs
drwx------. 5 vagrant vagrant 76 Feb 26 13:42 revoked
-rw-------. 1 vagrant vagrant 3 Feb 26 13:42 serial
-rw-------. 1 vagrant vagrant 9014 Feb 26 13:30 vars
-rw-------. 1 vagrant vagrant 9014 Feb 26 13:30 vars.example
Y su clave se encuentra en el directorio private/
:
$ ll pki/private
total 4
-rw-------. 1 vagrant vagrant 1874 Feb 26 13:43 ca.key
Podemos consultar la CA con el comando easyrsa show-ca
:
$ easyrsa show-ca
* Using SSL: openssl OpenSSL 1.1.1k FIPS 25 Mar 2021
* Using Easy-RSA configuration: pki/vars
Notice
------
Showing details for 'ca'.
This file is stored at:
* pki/ca.crt
Certificate:
Data:
Version: 3 (0x2)
Serial Number:
21:bb:a8:e4:a9:3e:56:e8:51:11:01:f3:79:75:60:c0:20:33:16:a4
Signature Algorithm: sha256WithRSAEncryption
Issuer:
commonName = infraestructurasbigdatacloud CA
Validity
Not Before: Feb 26 13:43:41 2023 GMT
Not After : Feb 23 13:43:41 2033 GMT
Subject:
commonName = infraestructurasbigdatacloud CA
X509v3 extensions:
X509v3 Basic Constraints:
CA:TRUE
X509v3 Subject Key Identifier:
85:8C:AE:BE:0B:53:87:9A:5B:40:52:6C:04:75:82:FC:F3:43:EE:5B
X509v3 Authority Key Identifier:
keyid:85:8C:AE:BE:0B:53:87:9A:5B:40:52:6C:04:75:82:FC:F3:43:EE:5B
DirName:/CN=infraestructurasbigdatacloud CA
serial:21:BB:A8:E4:A9:3E:56:E8:51:11:01:F3:79:75:60:C0:20:33:16:A4
X509v3 Key Usage:
Certificate Sign, CRL Sign
En el campo X509v3 Key Usage
podemos verificar que el certificado sirve para firmar otros certificados y CRLs.
Una vez creada la CA, se pueden emitir certificados para servidor ejecutando el comando easyrsa build-server-full <domain_name> nopass
. Al igual que en la generación de la CA, nos aparecerá un formulario interactivo para introducir la información necesaria.
$ easyrsa build-server-full infraestructurasbigdatacloud.es nopass
* Using SSL: openssl OpenSSL 1.1.1k FIPS 25 Mar 2021
* Using Easy-RSA configuration: pki/vars
Generating a RSA private key
.......................+++++
............................................................................+++++
writing new private key to 'pki/0fbc8aab/temp.ea507ed0'
-----
Notice
------
Keypair and certificate request completed. Your files are:
req: pki/reqs/infraestructurasbigdatacloud.es.req
key: pki/private/infraestructurasbigdatacloud.es.key
You are about to sign the following certificate.
Please check over the details shown below for accuracy. Note that this request
has not been cryptographically verified. Please be sure it came from a trusted
source or that you have verified the request checksum with the sender.
Request subject, to be signed as a server certificate for 825 days:
subject=
commonName = infraestructurasbigdatacloud.es
Type the word 'yes' to continue, or any other input to abort.
Confirm request details: yes
Using configuration from pki/0fbc8aab/temp.2050f531
Enter pass phrase for pki/private/ca.key:
Check that the request matches the signature
Signature ok
The Subject's Distinguished Name is as follows
commonName:ASN.1 12:'infraestructurasbigdatacloud.es'
Certificate is to be certified until Jun 1 14:11:46 2025 GMT (825 days)
Write out database with 1 new entries
Data Base Updated
Notice
------
Certificate created at:
* pki/issued/infraestructurasbigdatacloud.es.crt
Notice
------
Inline file created:
* pki/inline/infraestructurasbigdatacloud.es.inline
Y ya tenemos el certificado listo para instalar en el servidor web: pki/inline/infraestructurasbigdatacloud.es.inline
.
Este certificado es inline, es decir, que contiene la cadena completa necesaria:
También podemos consultar los certificados emitidos con el comando easyrsa show-cert <domain_name>
.
$ easyrsa show-cert infraestructurasbigdatacloud.es
* Using SSL: openssl OpenSSL 1.1.1k FIPS 25 Mar 2021
* Using Easy-RSA configuration: pki/vars
Notice
------
Showing cert details for: 'infraestructurasbigdatacloud.es'
This file is stored at:
* pki/issued/infraestructurasbigdatacloud.es.crt
Certificate:
Data:
Version: 3 (0x2)
Serial Number:
38:58:52:f6:45:93:b4:0e:0b:b9:d2:d6:5f:32:ad:f5
Signature Algorithm: sha256WithRSAEncryption
Issuer:
commonName = infraestructurasbigdatacloud CA
Validity
Not Before: Feb 26 14:11:46 2023 GMT
Not After : Jun 1 14:11:46 2025 GMT
Subject:
commonName = infraestructurasbigdatacloud.es
X509v3 extensions:
X509v3 Basic Constraints:
CA:FALSE
X509v3 Subject Key Identifier:
EE:0F:23:2F:2D:F9:73:2E:89:DA:DA:83:CD:42:43:99:53:47:9D:1E
X509v3 Authority Key Identifier:
keyid:85:8C:AE:BE:0B:53:87:9A:5B:40:52:6C:04:75:82:FC:F3:43:EE:5B
DirName:/CN=infraestructurasbigdatacloud CA
serial:21:BB:A8:E4:A9:3E:56:E8:51:11:01:F3:79:75:60:C0:20:33:16:A4
X509v3 Extended Key Usage:
TLS Web Server Authentication
X509v3 Key Usage:
Digital Signature, Key Encipherment
X509v3 Subject Alternative Name:
DNS:infraestructurasbigdatacloud.es
En este caso, vamos a crear un PKI simple para generar certificados para autenticación de clientes. Estos certificados serían necesarios, por ejemplo, para establecer una conexión de OpenVPN. Para ello, vamos a emitir una CA raíz, un CERT servidor y varios CERT clientes. Los emitiremos sin contraseña para facilitar su uso.
Podemos consultar el ejemplo anterior.
Podemos consultar el ejemplo anterior.
Podemos consultar el ejemplo anterior.
Al igual que certificados servidor, podemos emitir también certificados para cliente, ejecutando el comando easyrsa build-client-full <client_name> nopass
. En este caso, también nos aparecerá un formulario interactivo para introducir la información necesaria.
$ easyrsa build-client-full client1 nopass
* Using SSL: openssl OpenSSL 1.1.1k FIPS 25 Mar 2021
* Using Easy-RSA configuration: pki/vars
Generating a RSA private key
........................................+++++
...................................................................+++++
writing new private key to 'pki/25d9f9a8/temp.ab368c09'
-----
Notice
------
Keypair and certificate request completed. Your files are:
req: pki/reqs/client1.req
key: pki/private/client1.key
You are about to sign the following certificate.
Please check over the details shown below for accuracy. Note that this request
has not been cryptographically verified. Please be sure it came from a trusted
source or that you have verified the request checksum with the sender.
Request subject, to be signed as a client certificate for 825 days:
subject=
commonName = client1
Type the word 'yes' to continue, or any other input to abort.
Confirm request details: yes
Using configuration from pki/25d9f9a8/temp.753051c5
Enter pass phrase for pki/private/ca.key:
Check that the request matches the signature
Signature ok
The Subject's Distinguished Name is as follows
commonName :ASN.1 12:'client1'
Certificate is to be certified until Jun 1 17:55:35 2025 GMT (825 days)
Write out database with 1 new entries
Data Base Updated
Notice
------
Certificate created at:
* pki/issued/client1.crt
Notice
------
Inline file created:
* pki/inline/client1.inline
Y ya tenemos el certificado listo para el cliente: pki/inline/client1.inline
.
Este certificado, al igual que el de servidor, es inline, es decir, que contiene la cadena completa necesaria:
También podemos consultar este certificado con el comando easyrsa show-cert <client_name>
.
$ easyrsa show-cert client1
* Using SSL: openssl OpenSSL 1.1.1k FIPS 25 Mar 2021
* Using Easy-RSA configuration: pki/vars
Notice
------
Showing cert details for: 'client1'
This file is stored at:
* pki/issued/client1.crt
Certificate:
Data:
Version: 3 (0x2)
Serial Number:
cf:39:8d:f7:6d:9e:7b:8d:a7:34:10:12:f2:f6:71:40
Signature Algorithm: sha256WithRSAEncryption
Issuer:
commonName = infraestructurasbigdatacloud CA
Validity
Not Before: Feb 26 17:55:35 2023 GMT
Not After : Jun 1 17:55:35 2025 GMT
Subject:
commonName = client1
X509v3 extensions:
X509v3 Basic Constraints:
CA:FALSE
X509v3 Subject Key Identifier:
4C:57:CB:9F:0A:EC:3F:6E:C0:BB:A5:CD:98:20:2F:64:E7:36:CD:26
X509v3 Authority Key Identifier:
keyid:85:8C:AE:BE:0B:53:87:9A:5B:40:52:6C:04:75:82:FC:F3:43:EE:5B
DirName:/CN=infraestructurasbigdatacloud CA
serial:21:BB:A8:E4:A9:3E:56:E8:51:11:01:F3:79:75:60:C0:20:33:16:A4
X509v3 Extended Key Usage:
TLS Web Client Authentication
X509v3 Key Usage:
Digital Signature
En este ejemplo vamos a crear una estructura de CAs en jerarquía, donde cada certificado se representa como un nodo, estando la CA raíz en la parte superior de esta jerarquía. En la parte media tenemos las CAs intermedias, cada una para una finalidad concreta. En este ejemplo vamos a crear una CA intermedia para un servicio de VPN. Estas CAs intermedias, a su vez, firmarán los certificados finales de cliente y de servidor.
Al tratarse de una jerarquía de CAs, vamos a necesitar diferenes PKIs. Hay que entender bien que por cada CA, tendremos un PKI. Cada PKI contiene únicamente una CA y también los certificados que se firmen.
Vamos a crear 2 PKIs, uno por cada CA, de la misma forma que hicimos en el ejemplo 1.
$ cd ~/almacenes/
$ easyrsa --pki-dir=pkiROOT init-pki
Notice
------
'init-pki' complete; you may now create a CA or requests.
...
$ easyrsa --pki-dir=pkiVPN init-pki
Notice
------
'init-pki' complete; you may now create a CA or requests.
...
$ ll
total 0
drwx------. 2 vagrant vagrant 6 Feb 26 21:21 pkiROOT
drwx------. 2 vagrant vagrant 6 Feb 26 21:21 pkiVPN
Al igual que en el ejemplo 1, generamos la CA raíz.
$ easyrsa --pki-dir=pkiROOT build-ca
* Using SSL: openssl OpenSSL 1.1.1k FIPS 25 Mar 2021
* Using Easy-RSA configuration: pki/vars
Enter New CA Key Passphrase:
Confirm New CA Key Passphrase:
......+++++
............................................+++++
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.
-----
Common Name (eg: your user, host, or server name) [Easy-RSA CA]:ROOT CA
Notice
------
CA creation complete and you may now import and sign cert requests.
Your new CA certificate file for publishing is at:
pkiROOT/ca.crt
La generación de CAs intermedias conlleva 2 pasos principalmente:
Entonces, primero, vamos a generar el REQ de la CA intermedia, con el comando easyrsa build-ca subca
:
$ easyrsa --pki-dir=pkiVPN build-ca subca
* Using SSL: openssl OpenSSL 1.1.1k FIPS 25 Mar 2021
* Using Easy-RSA configuration: pki/vars
Enter New CA Key Passphrase:
Confirm New CA Key Passphrase:
....+++++
...............................................+++++
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.
-----
Common Name (eg: your user, host, or server name) [Easy-RSA Sub-CA]:VPN CA
Notice
------
NOTE: Your intermediate CA request is at pki/reqs/ca.req
and now must be sent to your parent CA for signing. Place your resulting cert
at pkiVPN/ca.crt prior to signing operations.
Ya tenemos listo el pkiVPN
.
Para firmar cada CA intermedia hay que:
Importemos el REQ con easyrsa import-req <request_file_path> <short_name_base>
:
$ easyrsa --pki-dir=pkiROOT import-req pkiVPN/reqs/ca.req subCAVPN
* Using SSL: openssl OpenSSL 1.1.1k FIPS 25 Mar 2021
* Using Easy-RSA configuration: pkiROOT/vars
Notice
------
The request has been successfully imported with a short name of: subCAVPN
You may now use this name to perform signing operations on this request.
Ahora vamos a firmar el certificado importado con easyrsa sign-req <type> <short_name_base>
:
$ easyrsa --pki-dir=pkiROOT sign-req ca subCAVPN
* Using SSL: openssl OpenSSL 1.1.1k FIPS 25 Mar 2021
* Using Easy-RSA configuration: pkiROOT/vars
You are about to sign the following certificate.
Please check over the details shown below for accuracy. Note that this request
has not been cryptographically verified. Please be sure it came from a trusted
source or that you have verified the request checksum with the sender.
Request subject, to be signed as a ca certificate for 825 days:
subject=
commonName = VPN CA
Type the word 'yes' to continue, or any other input to abort.
Confirm request details: yes
Using configuration from pki/a9cf3807/temp.ec747d3e
Enter pass phrase for pki/private/ca.key:
Check that the request matches the signature
Signature ok
The Subject's Distinguished Name is as follows
commonName :ASN.1 12:'VPN CA'
Certificate is to be certified until Jun 1 22:14:16 2025 GMT (825 days)
Write out database with 1 new entries
Data Base Updated
Notice
------
Certificate created at:
* pkiROOT/issued/subCAVPN.crt
Ya tenemos la CA VPN firmada por la CA ROOT. Ahora copiaremos el certificado firmado a su PKI:
$ ll
total 0
drwx------. 3 vagrant vagrant 17 Feb 26 21:26 pkiROOT
drwx------. 3 vagrant vagrant 17 Feb 26 21:31 pkiVPN
$ cp pkiROOT/issued/subCAVPN.crt pkiVPN/ca.crt
Con esto, ya tenemos completo el pkiVPN
. Lo comprobamos con easyrsa show-ca
:
$ easyrsa --pki-dir=pkiVPN show-ca
* Using SSL: openssl OpenSSL 1.1.1k FIPS 25 Mar 2021
* Using Easy-RSA configuration: pkiVPN/vars
Notice
------
Showing details for 'ca'.
This file is stored at:
* pkiVPN/ca.crt
Certificate:
Data:
Version: 3 (0x2)
Serial Number:
fa:23:8a:82:4e:46:c2:1e:0c:8d:52:2f:40:f2:97:2e
Signature Algorithm: sha256WithRSAEncryption
Issuer:
commonName = ROOT CA
Validity
Not Before: Feb 26 23:24:15 2023 GMT
Not After : Jun 1 23:24:15 2025 GMT
Subject:
commonName = VPN CA
X509v3 extensions:
X509v3 Basic Constraints:
CA:TRUE
X509v3 Subject Key Identifier:
42:1F:63:38:36:51:75:6C:F5:40:16:A3:B0:BF:71:C2:2D:3E:8C:20
X509v3 Authority Key Identifier:
keyid:A3:F0:68:A8:BB:2A:DD:96:53:A7:A1:52:FB:CB:11:25:05:D4:A6:7E
DirName:/CN=ROOT CA
serial:12:62:E5:B5:C7:AB:06:09:5E:64:B7:F4:FD:15:D6:B2:73:52:76:45
X509v3 Key Usage:
Certificate Sign, CRL Sign
En las líneas destacadas vemos que el issuer de esta CA es ROOT CA
.
Con esto, ya podemos generar los certificados servidor y cliente con ella, igual que en el ejemplo 1.3 y en el ejemplo 2.4.
Si queremos emitir certificados con todos los datos completos de una organización, es decir que no se incluya únicamente el common name, será necesario que, una vez creado el PKI, editemos el fichero vars
, en la línea 89:
vim pkiROOT/vars
|
|
Con esta modificación, al trabajar con los certificados de este PKI, los formularios interactivos nos preguntarán por todos los datos de la organización.
Pero si queremos que los datos los ponga por defecto, el mismo archivo vars
podemos editarlo de la siguiente forma:
vim pkiROOT/vars
|
|
Si queremos modificar el tamaño de las llaves generadas:
|
|
O, si queremos modificar los días de duración de los certificados:
|
|
|
|
Las nuevas versiones de EasyRSA incoporan un menú de ayuda muy completo y fácilmente comprensible. Se puede consultar con los comandos easyrsa help
, easyrsa help options
y easyrsa help <command>
.
EasyRSA funciona a la perfección con Git, por lo que os recomiendo encarecidamente que lo uséis como control de versiones del PKI. Siendo el PKI un almacén tan importante de conservar, con Git tendremos la herramienta perfecta para mantener el histórico de modificaciones, incluso podremos dar marcha atrás si la generación de algún certificado nos da problemas.
Como habrás podido comprobar, EasyRSA es la navaja suiza de los PKIs, facilitando la gestión completa del almacén. No te arrepentirás de incorporarlo a tu set de herramientas 🤩.
Si continúas navegando consideramos que aceptas la política del sitio. Más información X Cerrar