mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 19:11:53 +07:00
[PR #6651] [MERGED] fix(sub): emit Hysteria certificate pin for Mihomo #6396
Labels
No labels
backlog
bug
clarification needed
documentation
duplicate
enhancement
github_actions
good first issue
invalid
javascript
New Feature
PR welcomed
pull-request
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
MHSanaei/3x-ui#6396
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/MHSanaei/3x-ui/pull/6651
Author: @libmur-dev
Created: 9/25/2026
Status: ✅ Merged
Merged: 9/26/2026
Merged by: @MHSanaei
Base:
main← Head:fix/hysteria-mihomo-certificate-pin📝 Commits (2)
e2cca36fix(sub): emit Hysteria certificate pin for Mihomo9ad794fMerge branch 'main' into fix/hysteria-mihomo-certificate-pin📊 Changes
2 files changed (+120 additions, -0 deletions)
View changed files
📝
internal/sub/clash_service.go(+46 -0)📝
internal/sub/clash_service_test.go(+74 -0)📄 Description
Summary
Emit Hysteria/Hysteria2 server certificate pins as Mihomo's
fingerprintfieldin Clash/Mihomo subscriptions. Preserve
client-fingerprintas the separateuTLS client setting.
Why
For an IP-based Hysteria2 inbound with a self-signed certificate,
pinnedPeerCertSha256already appears aspinSHA256in the raw share link, butbuildHysteriaProxydrops it from/clash/and/mihomo/YAML. Mihomo thenfails certificate verification when
allowInsecureis disabled:The change normalizes the configured pin with the existing
hysteriaPinHexlogic, validates that it is a SHA-256 value, formats it as colon-separated
uppercase bytes, and emits it as
fingerprint. It also honors an externalendpoint pin override. Mihomo supports only one certificate
fingerprint, sowhen multiple pins are configured the first valid pin is exported in
configuration order.
Refs #4683. Related to #4818 and #4948.
Type of change
Areas affected
How was this tested?
Added
TestBuildHysteriaProxyIncludesCertificateFingerprint, using adeterministic SHA-256 value and TEST-NET address, and verifying that an
external endpoint pin overrides the inbound pin.
Added table-driven coverage confirming that an invalid first pin falls back
to the second valid pin and that two valid pins select the first.
Ran:
Result:
ok github.com/mhsanaei/3x-ui/v3/internal/sub 0.034s.Ran
go test ./...successfully on Ubuntu 24.04 with Go 1.27.1.Ran
go build ./...successfully in the same environment.Built and deployed a Linux amd64 panel binary from v3.8.5 on Debian 12.
Before the change, a valid subscription contained two Hysteria2 nodes and
zero certificate
fingerprintfields. After the change, it contained thesame two nodes and one expected certificate
fingerprintfield.Refreshed the subscription in FlClashX 0.4.2 with Mihomo 1.19.28 and
confirmed that the previously failing Hysteria2 node connected.
Screenshots / recordings
N/A — backend subscription serialization only.
Breaking changes
None. Existing Hysteria subscriptions without a valid configured certificate
pin are unchanged.
Checklist
go build ./...and the test suite pass locally.N/A, this restores an already configured certificate pin in another
subscription format.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.