Skip to content

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.

    openssl enc -aes-256-cbc -pbkdf2 -in file_received -out output.enc
    
    You will be prompted to enter a password.

  • Use cat to see the contents of the output.enc file. It should return gibberish text.
  • Decrypt the file output.enc using OpenSSL
    openssl enc -d -aes-256-cbc -pbkdf2 -in output.enc -out decrypted.txt
    
    You will be prompted to enter the password you have set previously.
  • Use cat to see the contents of the decrypted.txt file. It should return the same content as received_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.