Skip to content

Commit 9f9b90c

Browse files
authored
Add hysteria2 uri cert sha pinning support (#8657)
1 parent c42dcd2 commit 9f9b90c

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

v2rayN/ServiceLib/Handler/Fmt/Hysteria2Fmt.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ public class Hysteria2Fmt : BaseFmt
2525
ResolveUriQuery(query, ref item);
2626
item.Path = GetQueryDecoded(query, "obfs-password");
2727
item.Ports = GetQueryDecoded(query, "mport");
28+
if (item.CertSha.IsNullOrEmpty())
29+
{
30+
item.CertSha = GetQueryDecoded(query, "pinSHA256");
31+
}
2832

2933
return item;
3034
}
@@ -55,6 +59,16 @@ public class Hysteria2Fmt : BaseFmt
5559
{
5660
dicQuery.Add("mport", Utils.UrlEncode(item.Ports.Replace(':', '-')));
5761
}
62+
if (!item.CertSha.IsNullOrEmpty())
63+
{
64+
var sha = item.CertSha;
65+
var idx = sha.IndexOf('~');
66+
if (idx > 0)
67+
{
68+
sha = sha[..idx];
69+
}
70+
dicQuery.Add("pinSHA256", Utils.UrlEncode(sha));
71+
}
5872

5973
return ToUri(EConfigType.Hysteria2, item.Address, item.Port, item.Id, dicQuery, remark);
6074
}

0 commit comments

Comments
 (0)