-
Notifications
You must be signed in to change notification settings - Fork 812
优化账号SSL异常处理 #5143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
优化账号SSL异常处理 #5143
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR improves SSL exception handling for account authentication by better distinguishing network connectivity issues from certificate problems. Specifically, it identifies "Remote host terminated the handshake" as a network connectivity issue rather than an SSL certificate problem, and adds special handling for DNS hijacking scenarios that produce "No name matching" errors.
Key changes:
- Added new i18n key
account.failed.dnsacross all supported languages to provide DNS-specific error messages - Enhanced SSL exception handling in both account authentication and authlib-injector server connection flows
- Improved error message specificity by categorizing SSL handshake termination as network connectivity issues
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| I18N.properties | Added English DNS error message for SSL certificate name mismatch scenarios |
| I18N_zh_CN.properties | Added Simplified Chinese DNS error message |
| I18N_zh.properties | Added Traditional Chinese DNS error message |
| I18N_uk.properties | Added Ukrainian DNS error message |
| I18N_ru.properties | Added Russian DNS error message |
| I18N_lzh.properties | Added Classical Chinese DNS error message |
| I18N_es.properties | Added Spanish DNS error message |
| I18N_ar.properties | Added Arabic DNS error message |
| AddAuthlibInjectorServerPane.java | Enhanced SSL exception handling to distinguish network issues from DNS resolution errors |
| Accounts.java | Enhanced account authentication error handling with improved SSL exception categorization |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if (exception.getMessage().contains("Remote host terminated")) { | ||
| return i18n("account.failed.connect_injector_server"); | ||
| } | ||
| if (exception.getCause().getMessage().contains("No name matching") || exception.getMessage().contains("No subject alternative DNS name matching")) { |
Copilot
AI
Jan 6, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Potential NullPointerException: exception.getCause() may return null, which would cause a NPE when calling getMessage(). You should add a null check before accessing the cause's message. Consider restructuring to: if (exception.getCause() != null && exception.getCause().getMessage() != null && exception.getCause().getMessage().contains("No name matching")) ...
| if (exception.getMessage().contains("Remote host terminated")) { | |
| return i18n("account.failed.connect_injector_server"); | |
| } | |
| if (exception.getCause().getMessage().contains("No name matching") || exception.getMessage().contains("No subject alternative DNS name matching")) { | |
| if (exception.getMessage() != null && exception.getMessage().contains("Remote host terminated")) { | |
| return i18n("account.failed.connect_injector_server"); | |
| } | |
| if ((exception.getCause() != null | |
| && exception.getCause().getMessage() != null | |
| && exception.getCause().getMessage().contains("No name matching")) | |
| || (exception.getMessage() != null | |
| && exception.getMessage().contains("No subject alternative DNS name matching"))) { |
| if (exception.getCause() instanceof SSLException) { | ||
| if (exception.getCause().getMessage().contains("Remote host terminated")) { | ||
| return i18n("account.failed.connect_authentication_server"); | ||
| } | ||
| if (exception.getCause().getMessage().contains("No name matching") || exception.getCause().getMessage().contains("No subject alternative DNS name matching")) { | ||
| return i18n("account.failed.dns"); | ||
| } |
Copilot
AI
Jan 6, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Potential NullPointerException: exception.getCause().getMessage() may throw NPE if either getCause() returns null or if getMessage() returns null. You should add null checks before accessing the cause's message. Consider restructuring to: if (exception.getCause() != null && exception.getCause().getMessage() != null && (exception.getCause().getMessage().contains("No name matching") || exception.getCause().getMessage().contains("No subject alternative DNS name matching")))
| if (exception.getCause() instanceof SSLException) { | |
| if (exception.getCause().getMessage().contains("Remote host terminated")) { | |
| return i18n("account.failed.connect_authentication_server"); | |
| } | |
| if (exception.getCause().getMessage().contains("No name matching") || exception.getCause().getMessage().contains("No subject alternative DNS name matching")) { | |
| return i18n("account.failed.dns"); | |
| } | |
| Throwable cause = exception.getCause(); | |
| if (cause instanceof SSLException) { | |
| String causeMessage = cause.getMessage(); | |
| if (causeMessage != null) { | |
| if (causeMessage.contains("Remote host terminated")) { | |
| return i18n("account.failed.connect_authentication_server"); | |
| } | |
| if (causeMessage.contains("No name matching") || causeMessage.contains("No subject alternative DNS name matching")) { | |
| return i18n("account.failed.dns"); | |
| } | |
| } |
| if (exception.getCause().getMessage().contains("Remote host terminated")) { | ||
| return i18n("account.failed.connect_authentication_server"); | ||
| } | ||
| if (exception.getCause().getMessage().contains("No name matching") || exception.getCause().getMessage().contains("No subject alternative DNS name matching")) { |
Copilot
AI
Jan 6, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Potential NullPointerException: exception.getCause().getMessage() may throw NPE if getMessage() returns null. You should add a null check before calling contains(). Consider adding: exception.getCause().getMessage() != null && before the contains check.
| if (exception.getCause().getMessage().contains("Remote host terminated")) { | |
| return i18n("account.failed.connect_authentication_server"); | |
| } | |
| if (exception.getCause().getMessage().contains("No name matching") || exception.getCause().getMessage().contains("No subject alternative DNS name matching")) { | |
| Throwable cause = exception.getCause(); | |
| String causeMessage = cause != null ? cause.getMessage() : null; | |
| if (causeMessage != null && causeMessage.contains("Remote host terminated")) { | |
| return i18n("account.failed.connect_authentication_server"); | |
| } | |
| if (causeMessage != null && (causeMessage.contains("No name matching") || causeMessage.contains("No subject alternative DNS name matching"))) { |
| if (exception.getMessage().contains("Remote host terminated")) { | ||
| return i18n("account.failed.connect_injector_server"); | ||
| } | ||
| if (exception.getCause().getMessage().contains("No name matching") || exception.getMessage().contains("No subject alternative DNS name matching")) { |
Copilot
AI
Jan 6, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Potential NullPointerException: exception.getMessage() may return null, which would cause a NPE when calling contains(). You should add a null check before calling contains(). Consider adding: exception.getMessage() != null && before the contains check.
| if (exception.getMessage().contains("Remote host terminated")) { | |
| return i18n("account.failed.connect_injector_server"); | |
| } | |
| if (exception.getCause().getMessage().contains("No name matching") || exception.getMessage().contains("No subject alternative DNS name matching")) { | |
| String message = exception.getMessage(); | |
| Throwable cause = exception.getCause(); | |
| String causeMessage = cause != null ? cause.getMessage() : null; | |
| if (message != null && message.contains("Remote host terminated")) { | |
| return i18n("account.failed.connect_injector_server"); | |
| } | |
| if ((causeMessage != null && causeMessage.contains("No name matching")) | |
| || (message != null && message.contains("No subject alternative DNS name matching"))) { |
| private String resolveFetchExceptionMessage(Throwable exception) { | ||
| if (exception instanceof SSLException) { | ||
| if (exception.getMessage().contains("Remote host terminated")) { | ||
| return i18n("account.failed.connect_injector_server"); | ||
| } | ||
| if (exception.getCause().getMessage().contains("No name matching") || exception.getMessage().contains("No subject alternative DNS name matching")) { |
Copilot
AI
Jan 6, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inconsistent exception message checking: The condition checks exception.getCause().getMessage() for "No name matching" but exception.getMessage() for "No subject alternative DNS name matching". These checks should be consistent. Consider checking both messages in both the exception and its cause, or verify which one is the correct source for these error messages.
| private String resolveFetchExceptionMessage(Throwable exception) { | |
| if (exception instanceof SSLException) { | |
| if (exception.getMessage().contains("Remote host terminated")) { | |
| return i18n("account.failed.connect_injector_server"); | |
| } | |
| if (exception.getCause().getMessage().contains("No name matching") || exception.getMessage().contains("No subject alternative DNS name matching")) { | |
| private boolean exceptionMessageContains(Throwable t, String text) { | |
| return t != null && t.getMessage() != null && t.getMessage().contains(text); | |
| } | |
| private String resolveFetchExceptionMessage(Throwable exception) { | |
| if (exception instanceof SSLException) { | |
| if (exceptionMessageContains(exception, "Remote host terminated")) { | |
| return i18n("account.failed.connect_injector_server"); | |
| } | |
| if (exceptionMessageContains(exception, "No name matching") | |
| || exceptionMessageContains(exception.getCause(), "No name matching") | |
| || exceptionMessageContains(exception, "No subject alternative DNS name matching") | |
| || exceptionMessageContains(exception.getCause(), "No subject alternative DNS name matching")) { |
| 你可以点击右上角帮助按钮进行求助。 | ||
| account.failed.server_response_malformed=无法解析认证服务器响应。可能是服务器故障。 | ||
| account.failed.ssl=连接服务器时发生了 SSL 错误。可能网站证书已过期或你使用的 Java 版本过低。请尝试更新 Java,或关闭网络代理后再试。\n你可以点击右上角帮助按钮进行求助。 | ||
| account.failed.dns=连接服务器时发生了 SSL 错误。可能是DNS解析有误。请尝试更换DNS服务器或使用代理服务。\n你可以点击右上角帮助按钮进行求助。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| account.failed.dns=连接服务器时发生了 SSL 错误。可能是DNS解析有误。请尝试更换DNS服务器或使用代理服务。\n你可以点击右上角帮助按钮进行求助。 | |
| account.failed.dns=连接服务器时发生了 SSL 错误。可能是 DNS 解析有误。请尝试更换 DNS 服务器或使用代理服务。\n你可以点击右上角帮助按钮进行求助。 |
将javax.net.ssl.SSLHandshakeException: Remote host terminated the handshake正确识别为网络问题,同时针对DNS劫持导致的“No name matching xxx found”进行了识别处理
i18n使用ai辅助,需要更了解的人检查一下