Commit Graph
1 Commits
Author SHA1 Message Date
Matthew JohnsonandStevenson Michel 8b6870d7ee fix: add _aes attribute to Fernet256 for cryptography>=50.0.0 compatibility (#16654)
Cryptography 50.0.0 added a self._aes attribute to the Fernet class
constructor. Since Fernet256 overrides __init__ without calling
super().__init__(), it needs to manually set this attribute.

Without this attribute, any code using Fernet256 (encryption/decryption
of credentials, secrets, etc.) fails with:
    AttributeError: 'Fernet256' object has no attribute '_aes'

This fix:
- Imports algorithms from cryptography.hazmat.primitives.ciphers
- Sets self._aes = algorithms.AES(self._encryption_key) in __init__

The fix is backward compatible with cryptography < 50.0.0 since the
_aes attribute wasn't used by Fernet's methods in older versions.

Fixes: 277 test failures in AWX test suite when using cryptography 50.x
Related: pyca/cryptography#11234 (cryptography 50.0.0 changes)

Co-authored-by: Stevenson Michel <iamstevensonmichel@outlook.com>
2026-09-17 08:18:10 -04:00