fix(shell): 补齐 WinHTTP 的 WINHTTP_FLAG_SECURE,https api 的请求此前全部走明文
Docker Build / Build and Push Docker Image (push) Successful in 31s
Docker Build / Deploy to Server (push) Successful in 1s

现象:应用配了 login_mode=card,加壳后的客户端仍然显示「账号 + 密码 + 注册」
两个 tab、没有卡密输入框、没有充值入口;应用名却显示正确。

根因:壳里所有 WinHttpOpenRequest 的 dwFlags 都传 0。对 https 的 api,
WinHTTP 会用明文 HTTP 去连 443 端口,服务端(Caddy)直接回
400 The plain HTTP request was sent to HTTPS port。

而 api_get_sibling 的成功判据是 ok = (total > 0),400 的 HTML 错误页
同样算「成功」,于是 FetchAppInfo 继续往下走,对 HTML 做 json_str 解析,
全部失败,各个配置项静默回落到默认值 —— g_loginMode 停在 account、
g_billing 读不到,界面就是默认的账号登录。因为静默,所以查不出错。

应用名显示正确是另一条路径:json_str(g_cfg, "name", ...) 从 .vfy 里的
cfg 读,跟 /info 无关,所以它好着,掩盖了 /info 整体失败。

实测对比(同一 URL,wine + WinHTTP):
  dwFlags=0        → status=400  <html>400 The plain HTTP request was sent to HTTPS port
  dwFlags=SECURE   → status=200  {"code":200,"data":{"allowed_login_types":["card"],...}}

修复:
- shell9_v6.cpp(DuiLib 全部 7 套皮肤,64/32 位)5 处 WinHttpOpenRequest
  补 https ? WINHTTP_FLAG_SECURE : 0
- classic shell5.cpp / shell6.cpp 的登录另外还有 port 写死 80 的问题,
  一并按 scheme 判断改成 443,并补 SECURE 标志
- 重编 shell64_dui.bin / shell32_dui.bin 并更新 embed assets
This commit is contained in:
2026-11-29 08:49:42 +08:00
parent a2e41f659f
commit 1dc2dd78dd
5 changed files with 17 additions and 9 deletions
Binary file not shown.
Binary file not shown.
+5 -2
View File
@@ -444,11 +444,13 @@ static int http_login(const char *user, const char *pass, char *msg, int cap) {
snprintf(path, sizeof(path), "%s", g_api);
char *p = strstr(path, "://");
if (!p) return 0;
bool https = (p > path && p[-1] == 's');
p += 3;
char *slash = strchr(p, '/');
if (slash) { *slash = 0; snprintf(path, sizeof(path), "%s", slash + 1); }
snprintf(host, sizeof(host), "%s", p);
unsigned short port = 80;
// 原来写死 80:https 的 api 被当成明文 HTTP 发到 443,服务端回 400,登录恒失败。
unsigned short port = https ? 443 : 80;
char *colon = strrchr(host, ':');
if (colon) { *colon = 0; port = (unsigned short)atoi(colon + 1); }
MultiByteToWideChar(CP_UTF8, 0, host, -1, wHost, 256);
@@ -459,7 +461,8 @@ static int http_login(const char *user, const char *pass, char *msg, int cap) {
HINTERNET hS = WinHttpOpen(L"vfy/5.0", WINHTTP_ACCESS_TYPE_NO_PROXY, NULL, NULL, 0);
if (!hS) return 0;
HINTERNET hC = WinHttpConnect(hS, wHost, port, 0);
HINTERNET hR = hC ? WinHttpOpenRequest(hC, L"POST", wPath, NULL, NULL, NULL, 0) : NULL;
HINTERNET hR = hC ? WinHttpOpenRequest(hC, L"POST", wPath, NULL, NULL, NULL,
https ? WINHTTP_FLAG_SECURE : 0) : NULL;
if (hR) {
const wchar_t *hdr = L"Content-Type: application/json\r\n";
WinHttpSendRequest(hR, hdr, (DWORD)-1L, body, (DWORD)strlen(body), (DWORD)strlen(body), 0);
+7 -2
View File
@@ -530,6 +530,8 @@ static int api_call(const char *suffix, const char *body, char *resp, int cap) {
snprintf(full, sizeof(full), "%s", g_api);
char *p = strstr(full, "://");
if (!p) return 0;
// 判断 scheme:p 指向 "://" 的冒号,p[-1] 就是 http/https 的最后一个字母
bool https = (p > full && p[-1] == 's');
p += 3;
char *slash = strchr(p, '/');
char dir[400] = {0};
@@ -541,7 +543,9 @@ static int api_call(const char *suffix, const char *body, char *resp, int cap) {
}
char host[256];
snprintf(host, sizeof(host), "%s", p);
unsigned short port = 80;
// 原来写死 80:https 的 api 会被当成明文 HTTP 发到 443,服务端直接回
// 400 "The plain HTTP request was sent to HTTPS port",登录恒失败。
unsigned short port = https ? 443 : 80;
char *colon = strrchr(host, ':');
if (colon) { *colon = 0; port = (unsigned short)atoi(colon + 1); }
char path[512];
@@ -553,7 +557,8 @@ static int api_call(const char *suffix, const char *body, char *resp, int cap) {
HINTERNET hS = WinHttpOpen(L"vfy/6.0", WINHTTP_ACCESS_TYPE_NO_PROXY, NULL, NULL, 0);
if (!hS) return 0;
HINTERNET hC = WinHttpConnect(hS, wHost, port, 0);
HINTERNET hR = hC ? WinHttpOpenRequest(hC, L"POST", wPath, NULL, NULL, NULL, 0) : NULL;
HINTERNET hR = hC ? WinHttpOpenRequest(hC, L"POST", wPath, NULL, NULL, NULL,
https ? WINHTTP_FLAG_SECURE : 0) : NULL;
int ok = 0;
if (hR) {
const wchar_t *hdr = L"Content-Type: application/json\r\n";
+5 -5
View File
@@ -253,7 +253,7 @@ static int api_login(const char *user, const char *pass, char *msg, int cap) {
HINTERNET hS = WinHttpOpen(L"vfy/9.0", WINHTTP_ACCESS_TYPE_NO_PROXY, NULL, NULL, 0);
if (!hS) { snprintf(msg, cap, "网络初始化失败"); return 0; }
HINTERNET hC = WinHttpConnect(hS, wHost.c_str(), port, 0);
HINTERNET hR = hC ? WinHttpOpenRequest(hC, L"POST", wPath.c_str(), NULL, NULL, NULL, 0) : NULL;
HINTERNET hR = hC ? WinHttpOpenRequest(hC, L"POST", wPath.c_str(), NULL, NULL, NULL, https ? WINHTTP_FLAG_SECURE : 0) : NULL;
int ok = 0;
if (hR) {
WinHttpSendRequest(hR, L"Content-Type: application/json\r\n", (DWORD)-1,
@@ -320,7 +320,7 @@ static int api_register(const char *user, const char *email, const char *code,
HINTERNET hS = WinHttpOpen(L"vfy/9.0", WINHTTP_ACCESS_TYPE_NO_PROXY, NULL, NULL, 0);
if (!hS) { snprintf(msg, cap, "网络初始化失败"); return 0; }
HINTERNET hC = WinHttpConnect(hS, wHost.c_str(), port, 0);
HINTERNET hR = hC ? WinHttpOpenRequest(hC, L"POST", wPath.c_str(), NULL, NULL, NULL, 0) : NULL;
HINTERNET hR = hC ? WinHttpOpenRequest(hC, L"POST", wPath.c_str(), NULL, NULL, NULL, https ? WINHTTP_FLAG_SECURE : 0) : NULL;
int ok = 0;
if (hR) {
WinHttpSendRequest(hR, L"Content-Type: application/json\r\n", (DWORD)-1,
@@ -369,7 +369,7 @@ static int api_send_code(const char *email, const char *purpose, char *msg, int
HINTERNET hS = WinHttpOpen(L"vfy/9.0", WINHTTP_ACCESS_TYPE_NO_PROXY, NULL, NULL, 0);
if (!hS) { snprintf(msg, cap, "网络初始化失败"); return 0; }
HINTERNET hC = WinHttpConnect(hS, wHost.c_str(), port, 0);
HINTERNET hR = hC ? WinHttpOpenRequest(hC, L"POST", wPath.c_str(), NULL, NULL, NULL, 0) : NULL;
HINTERNET hR = hC ? WinHttpOpenRequest(hC, L"POST", wPath.c_str(), NULL, NULL, NULL, https ? WINHTTP_FLAG_SECURE : 0) : NULL;
int ok = 0;
if (hR) {
WinHttpSendRequest(hR, L"Content-Type: application/json\r\n", (DWORD)-1,
@@ -415,7 +415,7 @@ static int api_post_sibling(const char *sibling, const char *body, char *msg, in
HINTERNET hS = WinHttpOpen(L"vfy/9.0", WINHTTP_ACCESS_TYPE_NO_PROXY, NULL, NULL, 0);
if (!hS) { snprintf(msg, cap, "网络初始化失败"); return 0; }
HINTERNET hC = WinHttpConnect(hS, wHost.c_str(), port, 0);
HINTERNET hR = hC ? WinHttpOpenRequest(hC, L"POST", wPath.c_str(), NULL, NULL, NULL, 0) : NULL;
HINTERNET hR = hC ? WinHttpOpenRequest(hC, L"POST", wPath.c_str(), NULL, NULL, NULL, https ? WINHTTP_FLAG_SECURE : 0) : NULL;
int ok = 0;
if (hR) {
WinHttpSendRequest(hR, L"Content-Type: application/json\r\n", (DWORD)-1,
@@ -464,7 +464,7 @@ static int api_get_sibling(const char *sibling, char *resp, int cap) {
HINTERNET hS = WinHttpOpen(L"vfy/9.0", WINHTTP_ACCESS_TYPE_NO_PROXY, NULL, NULL, 0);
if (!hS) return 0;
HINTERNET hC = WinHttpConnect(hS, wHost.c_str(), port, 0);
HINTERNET hR = hC ? WinHttpOpenRequest(hC, L"GET", wPath.c_str(), NULL, NULL, NULL, 0) : NULL;
HINTERNET hR = hC ? WinHttpOpenRequest(hC, L"GET", wPath.c_str(), NULL, NULL, NULL, https ? WINHTTP_FLAG_SECURE : 0) : NULL;
int ok = 0;
if (hR) {
WinHttpSendRequest(hR, WINHTTP_NO_ADDITIONAL_HEADERS, 0, NULL, 0, 0, 0);