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_receivedusing OpenSSL.You will be prompted to enter a password.openssl enc -aes-256-cbc -pbkdf2 -in file_received -out output.enc - Use
catto see the contents of theoutput.encfile. It should return gibberish text. - Decrypt the file
output.encusing 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
catto see the contents of thedecrypted.txtfile. 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.