shadowsocks/shadowsocks-windows · error · System.Exception
method not found
Error message
method not found
What it means
Thrown from AEADEncryptor.InitEncryptorInfo when, after looking up the method in the cipher dictionary, CipherInfo.Type equals 0. A Type of 0 is the sentinel for 'unrecognised' in this codebase, so the requested AEAD method name is not among the AEAD ciphers returned by getCiphers(). Note this relies on the dictionary containing the key (else a KeyNotFoundException would fire first), so typically the key exists with Type 0.
Source
Thrown at shadowsocks-csharp/Encryption/AEAD/AEADEncryptor.cs:79
InitEncryptorInfo(method);
InitKey(password);
// Initialize all-zero nonce for each connection
_encNonce = new byte[nonceLen];
_decNonce = new byte[nonceLen];
}
protected abstract Dictionary<string, EncryptorInfo> getCiphers();
protected void InitEncryptorInfo(string method)
{
method = method.ToLower();
_method = method;
ciphers = getCiphers();
CipherInfo = ciphers[_method];
_innerLibName = CipherInfo.InnerLibName;
_cipher = CipherInfo.Type;
if (_cipher == 0) {
throw new System.Exception("method not found");
}
keyLen = CipherInfo.KeySize;
saltLen = CipherInfo.SaltSize;
tagLen = CipherInfo.TagSize;
nonceLen = CipherInfo.NonceSize;
}
protected void InitKey(string password)
{
byte[] passbuf = Encoding.UTF8.GetBytes(password);
// init master key
if (_Masterkey == null) _Masterkey = new byte[keyLen];
if (_Masterkey.Length != keyLen) Array.Resize(ref _Masterkey, keyLen);
DeriveKey(passbuf, _Masterkey, keyLen);
// init session key
if (_sessionKey == null) _sessionKey = new byte[keyLen];
}
View on GitHub (pinned to 891d971682)
Solutions
- Use an AEAD method name supported by the chosen backend (e.g. aes-256-gcm, aes-128-gcm, chacha20-ietf-poly1305).
- Verify the exact method string matches between client and server (lowercase, no extra whitespace).
- If the user should be able to pick any method, route stream ciphers to the non-AEAD encryptor instead of the AEAD one.
Example fix
// before
ciphers = getCiphers();
CipherInfo = ciphers[_method];
if (_cipher == 0) throw new System.Exception("method not found");
// after: fail with a helpful, specific message
if (!ciphers.TryGetValue(_method, out var info) || info.Type == 0)
throw new System.Exception($"AEAD method not found or unsupported: {_method}"); Defensive patterns
Strategy: validation
Validate before calling
// Validate method is in the AEAD set before constructing the encryptor
var aeadMethods = EncryptorFactory.GetAeadMethodNames();
if (!aeadMethods.Contains(method.ToLower()))
throw new ArgumentException($"Not an AEAD method: {method}"); Type guard
bool IsAeadMethod(string method, IEnumerable<string> known) =>
known.Contains((method ?? "").ToLower()); Try / catch
try { EncryptorFactory.GetEncryptor(method, password); }
catch (Exception ex) when (ex.Message == "method not found")
{ /* route to stream-cipher encryptor or report unsupported method */ } Prevention
- Match the method string exactly between client and server (lowercase).
- Surface supported method names in the UI selection list only.
- Reject legacy stream-cipher names when the AEAD path is required.
When it happens
Trigger: Passing a stream-cipher or legacy method name (e.g. "aes-256-cfb", "rc4-md5") to an AEAD-only encryptor; a typo in the method string; a method that the AEAD provider's cipher table maps to Type 0 because it is not supported by that backend.
Common situations: User selects a non-AEAD method while the AEAD path is active; config carries an old method after the server switched to AEAD; copy-paste of method names between server and client where one side only supports AEAD.
Related errors
- Cannot initialize mbed TLS cipher context
- failed to set key
- openssl: cipher not found
- openssl: fail to set key length
- openssl: fail to set AEAD nonce length
AI-assisted analysis of shadowsocks/shadowsocks-windows@891d971682 (2026-08-13).
Data as JSON: /api/errors/aab61fb447d47ff9.
Report an issue: GitHub.