SSL: capa de conexión segura, nos permite intercambiar información de forma cifrada a través de la red, dicho de otra forma, no visible para el resto.
El Java KeyStore (JKS) es un repositorio de certificados de confianza (con sus claves privadas). El propósito final es proveer las credenciales.
El TrustStore (JKS) es un repositorio de certificados de confianza (con sus claves publicas). Este sirve, por ejemplo, para negociar la conexión SSL entre el cliente y el servidor. El propósito final es validar las credenciales.
Two-Way SSL: es un método de autenticación donde la aplicación cliente verifica la identidad de la aplicación servidora y luego la servidora verifica la identidad del cliente.
Si hablamos de certificados, debemos aclarar el termino CA que se corresponde con una entidad certificadora (emite y revoca los certificados). Lo primero es confiar en la propia CA para lo que se suele recurrir a la instalación (añadir al truststore) del certificado autofirmado de la CA.
Comandos
- listar certificados en el keystore
- keytool -list -v -keystore $keystore.jks
- obtener los certificados del servidor
- openssl s_client -connect $ip:$port -prexit -showcerts
- Caducidad de un certificado .pem
- openssl x509 -in $cert -noout -enddate
- Información del certificado
openssl pkcs12 -in$cert.p12 -info- Generar un certificado .pem desde un p.12
- openssl pkcs12 -in $cert.p12 -out $finalCert.pem
- Importar un certificado de una CA en un keystore
- keytool -import -trustcacerts -alias root -file $cacert.crt -keystore $keystore.jks
- Generar un keystore con un certificado auto-firmado (para pruebas)
- keytool -genkey -keyalg RSA -alias $selfsignedAlias -keystore $keystore.jks -storepass $password -validity $numberDays -keysize 2048
- (otra opción) openssl req -new -x509 -sha256 -newkey rsa:2048 -days 365 -nodes -out /path/cert.pem -keyout /path/cert.key
____________________________________________
This blog post I'll try to explain several concepts and show the main commands about SSL.
SSL: Secure Sockets Layer, it makes encryption communication, so our information will not be visible to another person or system.
A Java KeyStore (JKS) is a repository of security certificates (with private keys). The final purpose is to provide the credentials.
A TrustStore (JKS) is a repository of security certificates (with public keys). This is useful for establish a SSL connection between a client and a server. The final purpose is to validate the credentials.
Two-way SSL: is a authentication method where client application verify the identity of the server application and, after that, server verify the identity of the client.
When we speak about certificates, we must considerer the CA, Certificate Authority (who releases and revokes the certificates). The first step is to trust in the CA so you must to install (add to truststore) the CA self-signed certificate.
Commands
The main commands to managament of certificates are offers by the keytool kit of Java.
- Listing of certificates in the keystore
- keytool -list -v -keystore $keystore.jks
- Getting all certificates from the server
- openssl s_client -connect $ip:$port -prexit -showcerts
- Getting informatión about the certificate
openssl pkcs12 -in$cert.p12 -info- Expiration date of a certificate (.pem format)
- openssl x509 -in $cert -noout -enddate
- Generating a certificate with format .pem from format p.12
- openssl pkcs12 -in $cert.p12 -out $finalCert.pem
- Import a root or intermediate CA certificate to an existing Java keystore
- keytool -import -trustcacerts -alias root -file $cacert.crt -keystore $keystore.jks
- Generate a keystore and self-signed certificate (for testing purposes)
- keytool -genkey -keyalg RSA -alias $selfsignedAlias -keystore $keystore.jks -storepass $password -validity $numberDays -keysize 2048
- (another option) openssl req -new -x509 -sha256 -newkey rsa:2048 -days 365 -nodes -out /path/cert.pem -keyout /path/cert.key
No hay comentarios:
Publicar un comentario