[GH-ISSUE #544] 部署到白山云时继续返回 400209 错误 #351

Closed
opened 2026-03-03 01:02:39 +03:00 by kerem · 6 comments
Owner

Originally created by @Anbool on GitHub (Mar 22, 2025).
Original GitHub issue: https://github.com/certimate-go/certimate/issues/544

版本号:0.3.5

问题:我注意到似乎已经是数组了,但不知道为什么仍然返回了错误。

日志:
[2025-03-22 14:07:20] ready to deploy ...
[2025-03-22 14:07:21] sdk request 'baishan.GetDomainConfig'
request:
{"domains":"google.com","config":["https"]}
response:
null
[2025-03-22 14:07:21] failed to deploy
[2025-03-22 14:07:21] failed to execute sdk request 'baishan.GetDomainConfig': baishan api error: unexpected status code: 400, {"code":400209,"message":"parameter config must be an array."}

我尝试对接口进行手动构建请求,可以按照预期返回。

示例:
curl 'https://cdn.api.baishan.com/v2/domain/config?token=token&domains=google.com&config[]=https'

响应体:
{
"code": 0,
"data": [
{
"domain": "google.com",
"domain_id": "106001",
"status": "serving",
"type": "dynamic",
"config": {
"https": {
"cert_id": 120610,
"http2": "on",
"force_https": "302",
"ocsp": "on"
}
}
}
]
}

Originally created by @Anbool on GitHub (Mar 22, 2025). Original GitHub issue: https://github.com/certimate-go/certimate/issues/544 版本号:0.3.5 问题:我注意到似乎已经是数组了,但不知道为什么仍然返回了错误。 日志: [2025-03-22 14:07:20] ready to deploy ... [2025-03-22 14:07:21] sdk request 'baishan.GetDomainConfig' request: {"domains":"google.com","config":["https"]} response: null [2025-03-22 14:07:21] failed to deploy [2025-03-22 14:07:21] failed to execute sdk request 'baishan.GetDomainConfig': baishan api error: unexpected status code: 400, {"code":400209,"message":"parameter config must be an array."} 我尝试对接口进行手动构建请求,可以按照预期返回。 示例: curl 'https://cdn.api.baishan.com/v2/domain/config?token=token&domains=google.com&config[]=https' 响应体: { "code": 0, "data": [ { "domain": "google.com", "domain_id": "106001", "status": "serving", "type": "dynamic", "config": { "https": { "cert_id": 120610, "http2": "on", "force_https": "302", "ocsp": "on" } } } ] }
kerem 2026-03-03 01:02:39 +03:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@fudiwei commented on GitHub (Mar 22, 2025):

config 传多个值的时候 URL 是啥样的?

<!-- gh-comment-id:2745106857 --> @fudiwei commented on GitHub (Mar 22, 2025): config 传多个值的时候 URL 是啥样的?
Author
Owner

@fudiwei commented on GitHub (Mar 22, 2025):

@Anbool 看起来白山云用了某种非标的 URL 传参方式,试着改了改。但我没有白山云账号,你可以帮我拉一下 commit 代码后用你的 Token 跑一下单测用例吗?

commit: 516a958c66

终端进入到项目的 internal/pkg/core/deployer/providers/baishan-cdn/ 目录下,执行:

# 请将参数替换为实际值
go test -v ./baishan_cdn_test.go -args --CERTIMATE_DEPLOYER_BAISHANCDN_INPUTCERTPATH="/path/to/your-input-cert.pem" --CERTIMATE_DEPLOYER_BAISHANCDN_INPUTKEYPATH="/path/to/your-input-key.pem" --CERTIMATE_DEPLOYER_BAISHANCDN_APITOKEN="your-api-token" --CERTIMATE_DEPLOYER_BAISHANCDN_DOMAIN="example.com"
<!-- gh-comment-id:2745190069 --> @fudiwei commented on GitHub (Mar 22, 2025): @Anbool 看起来白山云用了某种非标的 URL 传参方式,试着改了改。但我没有白山云账号,你可以帮我拉一下 commit 代码后用你的 Token 跑一下单测用例吗? commit: 516a958c66d8ec93d292731f57b4ad2e744fd089 终端进入到项目的 `internal/pkg/core/deployer/providers/baishan-cdn/` 目录下,执行: ```bash # 请将参数替换为实际值 go test -v ./baishan_cdn_test.go -args --CERTIMATE_DEPLOYER_BAISHANCDN_INPUTCERTPATH="/path/to/your-input-cert.pem" --CERTIMATE_DEPLOYER_BAISHANCDN_INPUTKEYPATH="/path/to/your-input-key.pem" --CERTIMATE_DEPLOYER_BAISHANCDN_APITOKEN="your-api-token" --CERTIMATE_DEPLOYER_BAISHANCDN_DOMAIN="example.com" ```
Author
Owner

@Anbool commented on GitHub (Mar 22, 2025):

@Anbool 看起来白山云用了某种非标的 URL 传参方式,试着改了改。但我没有白山云账号,你可以帮我拉一下 commit 代码后用你的 Token 跑一下单测用例吗?

commit: 516a958

终端进入到项目的 internal/pkg/core/deployer/providers/baishan-cdn/ 目录下,执行:

请将参数替换为实际值

go test -v ./baishan_cdn_test.go -args --CERTIMATE_DEPLOYER_BAISHANCDN_INPUTCERTPATH="/path/to/your-input-cert.pem" --CERTIMATE_DEPLOYER_BAISHANCDN_INPUTKEYPATH="/path/to/your-input-key.pem" --CERTIMATE_DEPLOYER_BAISHANCDN_APITOKEN="your-api-token" --CERTIMATE_DEPLOYER_BAISHANCDN_DOMAIN="example.com"

可以的,这两天测试后给你反馈

<!-- gh-comment-id:2745253913 --> @Anbool commented on GitHub (Mar 22, 2025): > [@Anbool](https://github.com/Anbool) 看起来白山云用了某种非标的 URL 传参方式,试着改了改。但我没有白山云账号,你可以帮我拉一下 commit 代码后用你的 Token 跑一下单测用例吗? > > commit: [516a958](https://github.com/usual2970/certimate/commit/516a958c66d8ec93d292731f57b4ad2e744fd089) > > 终端进入到项目的 `internal/pkg/core/deployer/providers/baishan-cdn/` 目录下,执行: > > # 请将参数替换为实际值 > go test -v ./baishan_cdn_test.go -args --CERTIMATE_DEPLOYER_BAISHANCDN_INPUTCERTPATH="/path/to/your-input-cert.pem" --CERTIMATE_DEPLOYER_BAISHANCDN_INPUTKEYPATH="/path/to/your-input-key.pem" --CERTIMATE_DEPLOYER_BAISHANCDN_APITOKEN="your-api-token" --CERTIMATE_DEPLOYER_BAISHANCDN_DOMAIN="example.com" 可以的,这两天测试后给你反馈
Author
Owner

@Anbool commented on GitHub (Mar 24, 2025):

我已经进行了测试并失败,以下是测试日志。不过值得一提的是,白山云 API 的接口传递数组参数确实是非标的:https://cdn.api.baishan.com/v2/domain/config?token=token&domains=www.test.com&config[]=referer&config[]=origin
代表查询 www.test.com 域名下的 referer 和 origin 配置。

root@Small-Build:/data/certimate# git status
HEAD detached at 516a958c
nothing to commit, working tree clean

root@Small-Build:/data/certimate# cd internal/pkg/core/deployer/providers/baishan-cdn/

root@Small-Build:/data/certimate/internal/pkg/core/deployer/providers/baishan-cdn# ls
baishan_cdn.go baishan_cdn_test.go

root@Small-Build:/data/certimate/internal/pkg/core/deployer/providers/baishan-cdn# go test -v ./baishan_cdn_test.go -args --CERTIMATE_DEPLOYER_BAISHANCDN_INPUTCERTPATH="/root/cert.pem" --CERTIMATE_DEPLOYER_BAISHANCDN_INPUTKEYPATH="/root/key.pem" --CERTIMATE_DEPLOYER_BAISHANCDN_APITOKEN="这是一个Token" --CERTIMATE_DEPLOYER_BAISHANCDN_DOMAIN="这是一个域名"

go: downloading github.com/pkg/errors v0.9.1
go: downloading github.com/go-resty/resty/v2 v2.16.5
go: downloading golang.org/x/net v0.37.0
=== RUN TestDeploy
=== RUN TestDeploy/Deploy
baishan_cdn_test.go:43: args:
INPUTCERTPATH: /root/cert.pem
INPUTKEYPATH: /root/key.pem
APITOKEN: 这是一个Token
DOMAIN: 这是一个域名
2025/03/24 02:46:59.513279 DEBUG RESTY

GET  /v2/domain/config?config%5B%5D=https&domains=这是一个域名&token=这是一个Token  HTTP/1.1
HOST   : cdn.api.baishan.com
HEADERS:
        User-Agent: go-resty/2.16.5 (https://github.com/go-resty/resty)
BODY   :
***** NO CONTENT *****
------------------------------------------------------------------------------
~~~ RESPONSE ~~~
STATUS       : 200 OK
PROTO        : HTTP/1.1
RECEIVED AT  : 2025-03-24T02:46:59.513170817Z
TIME DURATION: 845.792418ms
HEADERS      :
        Api-Id: 0
        Connection: keep-alive
        Content-Type: application/json; charset=utf-8
        Date: Mon, 24 Mar 2025 02:46:59 GMT
        Server: Apache/2.2.22 (Unix) mod_ssl/2.2.22 OpenSSL/1.0.1e-fips
        Vary: Accept-Encoding
        X-Frame-Options: SAMEORIGIN
        X-Ratelimit-Grad: minute
        X-Ratelimit-Limit: 80
        X-Ratelimit-Remaining: 80
        X-Retry-After: 1
        X-Ser: i48254_c14260, i59680_c22359, i45464_c18583
BODY         :
{
   "code": 0,
   "data": [
      {
         "domain": "这是一个域名",
         "domain_id": "这是一个域名ID",
         "status": "serving",
         "type": "dynamic",
         "config": {
            "https": {
               "cert_id": 这是一个证书ID,
               "http2": "on",
               "force_https": "302",
               "ocsp": "on"
            }
         }
      }
   ]
}
==============================================================================
    baishan_cdn_test.go:64: err: baishan api error: failed to parse response: json: cannot unmarshal string into Go struct field DomainCertificate.data.cert_id of type int64
        failed to execute sdk request 'baishan.CreateCertificate'
        github.com/usual2970/certimate/internal/pkg/core/deployer/providers/baishan-cdn.(*DeployerProvider).Deploy
                /data/certimate/internal/pkg/core/deployer/providers/baishan-cdn/baishan_cdn.go:86
        command-line-arguments_test.TestDeploy.func1
                /data/certimate/internal/pkg/core/deployer/providers/baishan-cdn/baishan_cdn_test.go:62
        testing.tRunner
                /usr/local/go/src/testing/testing.go:1792
        runtime.goexit
                /usr/local/go/src/runtime/asm_amd64.s:1700
--- FAIL: TestDeploy (1.01s)
    --- FAIL: TestDeploy/Deploy (1.01s)
FAIL
FAIL    command-line-arguments  1.010s
FAIL
<!-- gh-comment-id:2746753771 --> @Anbool commented on GitHub (Mar 24, 2025): 我已经进行了测试并失败,以下是测试日志。不过值得一提的是,白山云 API 的接口传递数组参数确实是非标的:https://cdn.api.baishan.com/v2/domain/config?token=token&domains=www.test.com&config[]=referer&config[]=origin 代表查询 www.test.com 域名下的 referer 和 origin 配置。 root@Small-Build:/data/certimate# git status HEAD detached at 516a958c nothing to commit, working tree clean root@Small-Build:/data/certimate# cd internal/pkg/core/deployer/providers/baishan-cdn/ root@Small-Build:/data/certimate/internal/pkg/core/deployer/providers/baishan-cdn# ls baishan_cdn.go baishan_cdn_test.go root@Small-Build:/data/certimate/internal/pkg/core/deployer/providers/baishan-cdn# go test -v ./baishan_cdn_test.go -args --CERTIMATE_DEPLOYER_BAISHANCDN_INPUTCERTPATH="/root/cert.pem" --CERTIMATE_DEPLOYER_BAISHANCDN_INPUTKEYPATH="/root/key.pem" --CERTIMATE_DEPLOYER_BAISHANCDN_APITOKEN="这是一个Token" --CERTIMATE_DEPLOYER_BAISHANCDN_DOMAIN="这是一个域名" go: downloading github.com/pkg/errors v0.9.1 go: downloading github.com/go-resty/resty/v2 v2.16.5 go: downloading golang.org/x/net v0.37.0 === RUN TestDeploy === RUN TestDeploy/Deploy baishan_cdn_test.go:43: args: INPUTCERTPATH: /root/cert.pem INPUTKEYPATH: /root/key.pem APITOKEN: 这是一个Token DOMAIN: 这是一个域名 2025/03/24 02:46:59.513279 DEBUG RESTY ============================================================================== ~~~ REQUEST ~~~ GET /v2/domain/config?config%5B%5D=https&domains=这是一个域名&token=这是一个Token HTTP/1.1 HOST : cdn.api.baishan.com HEADERS: User-Agent: go-resty/2.16.5 (https://github.com/go-resty/resty) BODY : ***** NO CONTENT ***** ------------------------------------------------------------------------------ ~~~ RESPONSE ~~~ STATUS : 200 OK PROTO : HTTP/1.1 RECEIVED AT : 2025-03-24T02:46:59.513170817Z TIME DURATION: 845.792418ms HEADERS : Api-Id: 0 Connection: keep-alive Content-Type: application/json; charset=utf-8 Date: Mon, 24 Mar 2025 02:46:59 GMT Server: Apache/2.2.22 (Unix) mod_ssl/2.2.22 OpenSSL/1.0.1e-fips Vary: Accept-Encoding X-Frame-Options: SAMEORIGIN X-Ratelimit-Grad: minute X-Ratelimit-Limit: 80 X-Ratelimit-Remaining: 80 X-Retry-After: 1 X-Ser: i48254_c14260, i59680_c22359, i45464_c18583 BODY : { "code": 0, "data": [ { "domain": "这是一个域名", "domain_id": "这是一个域名ID", "status": "serving", "type": "dynamic", "config": { "https": { "cert_id": 这是一个证书ID, "http2": "on", "force_https": "302", "ocsp": "on" } } } ] } ============================================================================== baishan_cdn_test.go:64: err: baishan api error: failed to parse response: json: cannot unmarshal string into Go struct field DomainCertificate.data.cert_id of type int64 failed to execute sdk request 'baishan.CreateCertificate' github.com/usual2970/certimate/internal/pkg/core/deployer/providers/baishan-cdn.(*DeployerProvider).Deploy /data/certimate/internal/pkg/core/deployer/providers/baishan-cdn/baishan_cdn.go:86 command-line-arguments_test.TestDeploy.func1 /data/certimate/internal/pkg/core/deployer/providers/baishan-cdn/baishan_cdn_test.go:62 testing.tRunner /usr/local/go/src/testing/testing.go:1792 runtime.goexit /usr/local/go/src/runtime/asm_amd64.s:1700 --- FAIL: TestDeploy (1.01s) --- FAIL: TestDeploy/Deploy (1.01s) FAIL FAIL command-line-arguments 1.010s FAIL
Author
Owner

@fudiwei commented on GitHub (Mar 24, 2025):

@Anbool 麻烦在现在的基础上再拉一下 commit 892256c0b9 ,重新跑一下单测看看。

<!-- gh-comment-id:2746786790 --> @fudiwei commented on GitHub (Mar 24, 2025): @Anbool 麻烦在现在的基础上再拉一下 commit 892256c0b91d15e5597528e71ff29a8353197128 ,重新跑一下单测看看。
Author
Owner

@Anbool commented on GitHub (Mar 24, 2025):

@fudiwei 看上去 github.com/usual2970/certimate@892256c0b9 测试已通过。

root@Small-Build:/data/certimate/internal/pkg/core/deployer/providers/baishan-cdn# go test -v ./baishan_cdn_test.go -args --CERTIMATE_DEPLOYER_BAISHANCDN_INPUTCERTPATH="/root/cert.pem" --CERTIMATE_DEPLOYER_BAISHANCDN_INPUTKEYPATH="/root/key.pem" --CERTIMATE_DEPLOYER_BAISHANCDN_APITOKEN="这是一个Token" --CERTIMATE_DEPLOYER_BAISHANCDN_DOMAIN="这是一个域名"
go: downloading github.com/pkg/errors v0.9.1
go: downloading github.com/go-resty/resty/v2 v2.16.5
go: downloading golang.org/x/net v0.37.0
=== RUN TestDeploy
=== RUN TestDeploy/Deploy
baishan_cdn_test.go:43: args:
INPUTCERTPATH: /root/cert.pem
INPUTKEYPATH: /root/key.pem
APITOKEN: 这是一个Token
DOMAIN: 这是一个域名
baishan_cdn_test.go:64: err: baishan api error: unexpected status code: 400, {"code":400699,"message":"this certificate is exists, cert_id is (这是一个证书ID)"}
failed to execute sdk request 'baishan.CreateCertificate'
github.com/usual2970/certimate/internal/pkg/core/deployer/providers/baishan-cdn.(*DeployerProvider).Deploy
/data/certimate/internal/pkg/core/deployer/providers/baishan-cdn/baishan_cdn.go:86
command-line-arguments_test.TestDeploy.func1
/data/certimate/internal/pkg/core/deployer/providers/baishan-cdn/baishan_cdn_test.go:62
testing.tRunner
/usr/local/go/src/testing/testing.go:1792
runtime.goexit
/usr/local/go/src/runtime/asm_amd64.s:1700
--- FAIL: TestDeploy (1.25s)
--- FAIL: TestDeploy/Deploy (1.25s)
FAIL
FAIL command-line-arguments 1.255s
FAIL

<!-- gh-comment-id:2746802044 --> @Anbool commented on GitHub (Mar 24, 2025): @fudiwei 看上去 https://github.com/usual2970/certimate/commit/892256c0b91d15e5597528e71ff29a8353197128 测试已通过。 root@Small-Build:/data/certimate/internal/pkg/core/deployer/providers/baishan-cdn# go test -v ./baishan_cdn_test.go -args --CERTIMATE_DEPLOYER_BAISHANCDN_INPUTCERTPATH="/root/cert.pem" --CERTIMATE_DEPLOYER_BAISHANCDN_INPUTKEYPATH="/root/key.pem" --CERTIMATE_DEPLOYER_BAISHANCDN_APITOKEN="这是一个Token" --CERTIMATE_DEPLOYER_BAISHANCDN_DOMAIN="这是一个域名" go: downloading github.com/pkg/errors v0.9.1 go: downloading github.com/go-resty/resty/v2 v2.16.5 go: downloading golang.org/x/net v0.37.0 === RUN TestDeploy === RUN TestDeploy/Deploy baishan_cdn_test.go:43: args: INPUTCERTPATH: /root/cert.pem INPUTKEYPATH: /root/key.pem APITOKEN: 这是一个Token DOMAIN: 这是一个域名 baishan_cdn_test.go:64: err: baishan api error: unexpected status code: 400, {"code":400699,"message":"this certificate is exists, cert_id is (这是一个证书ID)"} failed to execute sdk request 'baishan.CreateCertificate' github.com/usual2970/certimate/internal/pkg/core/deployer/providers/baishan-cdn.(*DeployerProvider).Deploy /data/certimate/internal/pkg/core/deployer/providers/baishan-cdn/baishan_cdn.go:86 command-line-arguments_test.TestDeploy.func1 /data/certimate/internal/pkg/core/deployer/providers/baishan-cdn/baishan_cdn_test.go:62 testing.tRunner /usr/local/go/src/testing/testing.go:1792 runtime.goexit /usr/local/go/src/runtime/asm_amd64.s:1700 --- FAIL: TestDeploy (1.25s) --- FAIL: TestDeploy/Deploy (1.25s) FAIL FAIL command-line-arguments 1.255s FAIL
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/certimate#351
No description provided.