{"record":{"id":"58072f1670da1f6d","repo":"shadowsocks/shadowsocks-windows","slug":"openssl-cipher-not-found","errorCode":null,"errorMessage":"openssl: cipher not found","messagePattern":"openssl: cipher not found","errorType":"exception","errorClass":"System.Exception","httpStatus":null,"severity":"critical","filePath":"shadowsocks-csharp/Encryption/AEAD/AEADOpenSSLEncryptor.cs","lineNumber":50,"sourceCode":"            {\"aes-256-gcm\", new EncryptorInfo(\"aes-256-gcm\", 32, 32, 12, 16, CIPHER_AES)},\r\n            {\"chacha20-ietf-poly1305\", new EncryptorInfo(\"chacha20-poly1305\", 32, 32, 12, 16, CIPHER_CHACHA20IETFPOLY1305)}\r\n        };\r\n\r\n        public static List<string> SupportedCiphers()\r\n        {\r\n            return new List<string>(_ciphers.Keys);\r\n        }\r\n\r\n        protected override Dictionary<string, EncryptorInfo> getCiphers()\r\n        {\r\n            return _ciphers;\r\n        }\r\n\r\n        public override void InitCipher(byte[] salt, bool isEncrypt, bool isUdp)\r\n        {\r\n            base.InitCipher(salt, isEncrypt, isUdp);\r\n            _cipherInfoPtr = OpenSSL.GetCipherInfo(_innerLibName);\r\n            if (_cipherInfoPtr == IntPtr.Zero) throw new System.Exception(\"openssl: cipher not found\");\r\n            IntPtr ctx = OpenSSL.EVP_CIPHER_CTX_new();\r\n            if (ctx == IntPtr.Zero) throw new System.Exception(\"openssl: fail to create ctx\");\r\n\r\n            if (isEncrypt)\r\n            {\r\n                _encryptCtx = ctx;\r\n            }\r\n            else\r\n            {\r\n                _decryptCtx = ctx;\r\n            }\r\n\r\n            DeriveSessionKey(isEncrypt ? _encryptSalt : _decryptSalt, _Masterkey,\r\n                isEncrypt ? _opensslEncSubkey : _opensslDecSubkey);\r\n\r\n            var ret = OpenSSL.EVP_CipherInit_ex(ctx, _cipherInfoPtr, IntPtr.Zero, null, null,\r\n                isEncrypt ? OpenSSL.OPENSSL_ENCRYPT : OpenSSL.OPENSSL_DECRYPT);\r\n            if (ret != 1) throw new System.Exception(\"openssl: fail to init ctx\");\r","sourceCodeStart":32,"sourceCodeEnd":68,"githubUrl":"https://github.com/shadowsocks/shadowsocks-windows/blob/891d971682eefcaa2e640258d3b352a3ad3b2233/shadowsocks-csharp/Encryption/AEAD/AEADOpenSSLEncryptor.cs#L32-L68","documentation":"Thrown from AEADOpenSSLEncryptor.InitCipher when OpenSSL.GetCipherInfo(_innerLibName) returns IntPtr.Zero, meaning the OpenSSL EVP_CIPHER for the requested algorithm name could not be found. This is the OpenSSL analogue of error 9: the bundled/linked OpenSSL build does not provide that cipher.","triggerScenarios":"_innerLibName (e.g. \"aes-256-gcm\", \"chacha20-poly1305\") is not compiled into the OpenSSL library in use; a typo or wrong naming (OpenSSL expects specific EVP names like \"aes-256-gcm\"); an older OpenSSL 1.0.x lacking AEAD ciphers.","commonSituations":"Shipping OpenSSL without AEAD support; version downgrade of the native lib; platform (e.g. some mobile/embedded) with a stripped OpenSSL; method name format mismatch between mbedTLS and OpenSSL tables.","solutions":["Use an OpenSSL build compiled with AEAD ciphers (AES-NI/GCM, CHACHA20-POLY1305).","Verify _innerLibName matches an EVP name OpenSSL recognises (EVP_get_cipherbyname).","Fall back to the mbedTLS encryptor if OpenSSL lacks the cipher."],"exampleFix":"// before\n_cipherInfoPtr = OpenSSL.GetCipherInfo(_innerLibName);\nif (_cipherInfoPtr == IntPtr.Zero) throw new System.Exception(\"openssl: cipher not found\");\n\n// after\nif (_cipherInfoPtr == IntPtr.Zero)\n    throw new System.Exception($\"openssl: cipher not found for {_innerLibName} (rebuild OpenSSL with AEAD support)\");","handlingStrategy":"fallback","validationCode":"// Check OpenSSL cipher availability before init\nif (OpenSSL.GetCipherInfo(_innerLibName) == IntPtr.Zero)\n    throw new System.Exception($\"OpenSSL lacks {_innerLibName}\");","typeGuard":"bool OpenSSLSupportsCipher(string innerName) =>\n    OpenSSL.GetCipherInfo(innerName) != IntPtr.Zero;","tryCatchPattern":"try { useOpenSSL(); }\ncatch (Exception ex) when (ex.Message.Contains(\"openssl: cipher not found\"))\n{ /* fall back to mbedTLS AEAD encryptor */ }","preventionTips":["Ship OpenSSL built with AEAD ciphers (AES-GCM, CHACHA20-POLY1305).","Verify _innerLibName is a recognised EVP name.","Probe cipher availability at startup for all configured methods."],"tags":["encryption","aead","openssl","cipher","native-library"],"backgroundTag":null,"analyzedSha":"891d971682eefcaa2e640258d3b352a3ad3b2233","analyzedAt":"2026-08-13T10:12:34.434Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}