Practice Exercise 4: OpenSSL
Objectives
Perform various encryption and certificate management tasks using OpenSSL.
Tasks
-
Generate a self-signed SSL certificate with OpenSSL:
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout server.key -out server.crt
-
Encrypt the file
file_received
using OpenSSL.You will be prompted to enter a password.openssl enc -aes-256-cbc -pbkdf2 -in file_received -out output.enc
- Use
cat
to see the contents of theoutput.enc
file. It should return gibberish text. - Decrypt the file
output.enc
using OpenSSLYou will be prompted to enter the password you have set previously.openssl enc -d -aes-256-cbc -pbkdf2 -in output.enc -out decrypted.txt
- Use
cat
to see the contents of thedecrypted.txt
file. It should return the same content asreceived_file
Conclusion
In conclusion, these activities demonstrate how to use OpenSSL for the generation of self-signed SSL certificates, encryption of files, and decryption of encrypted files.