OpenSSL in Python: Secure File With Keys and Certificates
Guard The Cluster
8 min readOct 3, 2024
Set Up Trusted Group
_
1. Key and Certificate Creation: The process illustrates by creating RSA key pairs and X.509 certificates for each user (3 recipients and 1 self).2. Symmetric Key Generation: A random AES symmetric key is generated for encrypting a file.2. File Encryption: The file contents are encrypted using the generated symmetric key.3. Symmetric Key Encryption: Each user’s symmetric key is encrypted with their public certificate.4. File Signing: The file is signed using the self-certificate's private key.5. Signature Verification: Each user verifies the file's signature using the sender's public key.6. Key Decryption: Each user decrypts the symmetric key using their private key.7. File Decryption: Each user decrypts the encrypted file using the decrypted symmetric key and prints the original message.
_
Group Key and Certificate Creation
from cryptography import x509
from cryptography.x509.oid import NameOID
from cryptography.hazmat.primitives import hashes…