AlexxIT/go2rtc · error
failed to encrypt password
Error message
failed to encrypt password: %v
What it means
Wraps an error from tuya.EncryptPassword, which failed to encrypt the user's password with the public key returned by the login-token endpoint. Indicates the Tuya password-login flow cannot proceed; surfaces to apiTuya as a login failure, typically due to an empty/invalid RSA public key from getLoginToken.
Solutions
- Verify the account password is correct and non-empty
- Retry login to obtain a fresh PbKey from the token endpoint
- Check that the Tuya region/appKey configuration is valid so the token response contains a usable key
Defensive patterns
Strategy: retry
When it happens
Trigger: Thrown at internal/tuya/tuya.go:132 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of AlexxIT/go2rtc@c245815e75 (2026-09-07).
Data as JSON: /api/errors/05f4bded82a623df.
Report an issue: GitHub.
Appendix: source
Thrown at internal/tuya/tuya.go:132
items = append(items, &api.Source{
Name: device.DeviceName,
URL: url,
})
}
api.ResponseSources(w, items)
}
func login(client *http.Client, serverHost, email, password, countryCode string) (*tuya.LoginResult, error) {
tokenResp, err := getLoginToken(client, serverHost, email, countryCode)
if err != nil {
return nil, err
}
encryptedPassword, err := tuya.EncryptPassword(password, tokenResp.Result.PbKey)
if err != nil {
return nil, fmt.Errorf("failed to encrypt password: %v", err)
}
var loginResp *tuya.PasswordLoginResponse
var url string
loginReq := tuya.PasswordLoginRequest{
CountryCode: countryCode,
Passwd: encryptedPassword,
Token: tokenResp.Result.Token,
IfEncrypt: 1,
Options: `{"group":1}`,
}
if tuya.IsEmailAddress(email) {
url = fmt.Sprintf("https://%s/api/private/email/login", serverHost)
loginReq.Email = email
} else {
url = fmt.Sprintf("https://%s/api/private/phone/login", serverHost)View on GitHub (pinned to c245815e75)