{"record":{"id":"318ac07fd28876c1","repo":"Billionmail/BillionMail","slug":"dns-automated-resolution-failed-apikey-or-secretk","errorCode":null,"errorMessage":"DNS automated resolution failed: APIKey or SecretKey is empty in AliDNS configuration file","messagePattern":"DNS automated resolution failed: APIKey or SecretKey is empty in AliDNS configuration file","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/internal/service/acme/acme.go","lineNumber":158,"sourceCode":"\t\treturn errors.New(public.LangCtx(ctx, \"DNS provider initialization failed: {}\", err.Error()))\n\t}\n\n\terr = client.Challenge.SetDNS01Provider(p)\n\tif err != nil {\n\t\treturn errors.New(public.LangCtx(ctx, \"DNS verification setup failed: {}\", err.Error()))\n\t}\n\treturn nil\n}\n\n/**\n * @description: Configure DNS verification via Alibaba Cloud\n * @param {*lego.Client} client Client\n * @param {map[string]string} keyConfig Configuration information\n * @return error Error information\n */\nfunc SetDnsAliyun(ctx context.Context, client *lego.Client, keyConfig map[string]string) error {\n\tif keyConfig == nil || keyConfig[\"APIKey\"] == \"\" || keyConfig[\"SecretKey\"] == \"\" {\n\t\treturn errors.New(public.LangCtx(ctx, \"DNS automated resolution failed: APIKey or SecretKey is empty in AliDNS configuration file\"))\n\t}\n\n\tcfg := alidns.NewDefaultConfig()\n\tcfg.APIKey = keyConfig[\"APIKey\"]\n\tcfg.SecretKey = keyConfig[\"SecretKey\"]\n\n\tp, err := alidns.NewDNSProviderConfig(cfg)\n\tif err != nil {\n\t\treturn errors.New(public.LangCtx(ctx, \"DNS provider initialization failed: {}\", err.Error()))\n\t}\n\n\terr = client.Challenge.SetDNS01Provider(p)\n\tif err != nil {\n\t\treturn errors.New(public.LangCtx(ctx, \"DNS verification setup failed: {}\", err.Error()))\n\t}\n\n\treturn nil\n}","sourceCodeStart":140,"sourceCodeEnd":176,"githubUrl":"https://github.com/Billionmail/BillionMail/blob/fc36c76c050c3775c5e899faf7403cf0262d2744/core/internal/service/acme/acme.go#L140-L176","documentation":"SetDnsAliyun configures the lego Alibaba Cloud (alidns) DNS-01 provider. It first validates keyConfig: if the map is nil or 'APIKey' (AccessKey ID) / 'SecretKey' (AccessKey Secret) are empty, it fails fast with this message. Alibaba Cloud DNS API calls require both an AccessKey ID and matching secret for signature authentication.","triggerScenarios":"Calling ApplySSLWithExistingServer with dnsProvider 'alidns' whose keyConfig is nil or has empty 'APIKey'/'SecretKey' entries (acme.go:157-159).","commonSituations":"Aliyun AccessKey created but only the ID stored; RAM user without enabled programmatic access keys; map keys renamed (e.g. 'AccessKeyId') so lookups return empty strings; DNS config never saved for the domain.","solutions":["Set both keyConfig[\"APIKey\"] (AccessKey ID) and keyConfig[\"SecretKey\"] (AccessKey Secret) to non-empty values.","Confirm exact map key spellings: 'APIKey' and 'SecretKey'.","Create an Aliyun RAM AccessKey pair with DNS (alidns) permissions if credentials are missing.","Re-save the provider config in the UI/database and verify the row is populated."],"exampleFix":"// before\nkeyConfig := map[string]string{\"AccessKeyId\": ak} // wrong keys\n// after\nkeyConfig := map[string]string{\"APIKey\": ak, \"SecretKey\": sk}","handlingStrategy":"validation","validationCode":"if ak, sk := keyConfig[\"APIKey\"], keyConfig[\"SecretKey\"]; ak == \"\" || sk == \"\" {\n    return errors.New(\"alidns DNS config requires non-empty APIKey and SecretKey\")\n}","typeGuard":"func hasAliyunKeys(m map[string]string) bool {\n    return m != nil && m[\"APIKey\"] != \"\" && m[\"SecretKey\"] != \"\"\n}","tryCatchPattern":null,"preventionTips":["Store Aliyun credentials under the exact keys APIKey and SecretKey.","Validate non-empty credentials when the user saves the DNS config.","Ensure RAM AccessKeys are created with programmatic access.","Scope the AccessKey to alidns permissions only."],"tags":["dns","acme","alidns","missing-credentials","config"],"backgroundTag":"missing-api-credentials","analyzedSha":"fc36c76c050c3775c5e899faf7403cf0262d2744","analyzedAt":"2026-09-05T21:28:54.019Z","contentChangedAt":"2026-09-05T21:28:54.019Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}