Skip to content

Conversation

@Xirren
Copy link
Contributor

@Xirren Xirren commented Jan 5, 2026

将javax.net.ssl.SSLHandshakeException: Remote host terminated the handshake正确识别为网络问题,同时针对DNS劫持导致的“No name matching xxx found”进行了识别处理
i18n使用ai辅助,需要更了解的人检查一下

Copy link
Contributor

Copilot AI left a 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.dns across 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.

Comment on lines 167 to 170
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")) {
Copy link

Copilot AI Jan 6, 2026

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")) ...

Suggested change
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"))) {

Copilot uses AI. Check for mistakes.
Comment on lines 416 to 422
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");
}
Copy link

Copilot AI Jan 6, 2026

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")))

Suggested change
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");
}
}

Copilot uses AI. Check for mistakes.
Comment on lines 417 to 420
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")) {
Copy link

Copilot AI Jan 6, 2026

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.

Suggested change
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"))) {

Copilot uses AI. Check for mistakes.
Comment on lines 167 to 170
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")) {
Copy link

Copilot AI Jan 6, 2026

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.

Suggested change
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"))) {

Copilot uses AI. Check for mistakes.
Comment on lines 165 to 170
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")) {
Copy link

Copilot AI Jan 6, 2026

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.

Suggested change
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")) {

Copilot uses AI. Check for mistakes.
你可以点击右上角帮助按钮进行求助。
account.failed.server_response_malformed=无法解析认证服务器响应。可能是服务器故障。
account.failed.ssl=连接服务器时发生了 SSL 错误。可能网站证书已过期或你使用的 Java 版本过低。请尝试更新 Java,或关闭网络代理后再试。\n你可以点击右上角帮助按钮进行求助。
account.failed.dns=连接服务器时发生了 SSL 错误。可能是DNS解析有误。请尝试更换DNS服务器或使用代理服务。\n你可以点击右上角帮助按钮进行求助。
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
account.failed.dns=连接服务器时发生了 SSL 错误。可能是DNS解析有误。请尝试更换DNS服务器或使用代理服务。\n你可以点击右上角帮助按钮进行求助。
account.failed.dns=连接服务器时发生了 SSL 错误。可能是 DNS 解析有误。请尝试更换 DNS 服务器或使用代理服务。\n你可以点击右上角帮助按钮进行求助。

Co-authored-by: 3gf8jv4dv <3gf8jv4dv@gmail.com>
@Glavo Glavo merged commit 0705465 into HMCL-dev:main Jan 7, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants