{"record":{"id":"c23a4bf32d5846a6","repo":"justauth/JustAuth","slug":"cause-message","errorCode":null,"errorMessage":"${cause.message}","messagePattern":"\\$\\{cause\\.message\\}","errorType":"exception","errorClass":"AuthException","httpStatus":null,"severity":"critical","filePath":"src/main/java/me/zhyd/oauth/request/AuthAlipayCertRequest.java","lineNumber":40,"sourceCode":"import me.zhyd.oauth.utils.UrlBuilder;\n\nimport static me.zhyd.oauth.config.AuthDefaultSource.ALIPAY;\n\n/**\n * 支付宝证书模式登录\n *\n * @since 1.16.7\n */\npublic class AuthAlipayCertRequest extends AuthDefaultRequest {\n\n    private final AlipayClient alipayClient;\n\n    public AuthAlipayCertRequest(AuthConfig config, AlipayConfig alipayConfig) {\n        super(config, ALIPAY);\n        try {\n            this.alipayClient = new DefaultAlipayClient(alipayConfig);\n        } catch (AlipayApiException e) {\n            throw new AuthException(e);\n        }\n    }\n\n    @Override\n    protected void checkCode(AuthCallback authCallback) {\n        if (StringUtils.isEmpty(authCallback.getAuth_code())) {\n            throw new AuthException(AuthResponseStatus.ILLEGAL_CODE, source);\n        }\n    }\n\n    @Override\n    public AuthToken getAccessToken(AuthCallback authCallback) {\n        AlipaySystemOauthTokenRequest request = new AlipaySystemOauthTokenRequest();\n        request.setGrantType(\"authorization_code\");\n        request.setCode(authCallback.getAuth_code());\n        AlipaySystemOauthTokenResponse response;\n        try {\n            response = this.alipayClient.certificateExecute(request);","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/justauth/JustAuth/blob/694bbf1b010d93404e3bfb4824d90e9ddfaebebb/src/main/java/me/zhyd/oauth/request/AuthAlipayCertRequest.java#L22-L58","documentation":"AuthAlipayCertRequest's constructor wraps DefaultAlipayClient in a try/catch and rethrows AlipayApiException as AuthException(cause). This fires at request-construction time when the Alipay SDK rejects the AlipayConfig: malformed or unreadable certificate/key resources, wrong private-key format, or incompatible gateway URL. The AuthException's message comes from the cause.","triggerScenarios":"new AuthAlipayCertRequest(authConfig, alipayConfig) where alipayConfig points at certificate paths/contents the Alipay SDK cannot load (alipayPublicCertPath, appCertPath, rootCertPath, privateKey) or the gateway URL is malformed; file paths valid at build time but missing at runtime.","commonSituations":"Cert files not packaged into the jar/deployment (path works locally, fails in Docker); mixing public-key mode config with certificate mode; pasting the private key with headers/whitespace damage; wrong format (PKCS1 vs PKCS8) for the configured sign type.","solutions":["Read e.getCause() (AlipayApiException) — its message names exactly which resource/step failed.","Verify all certificate paths and the private key in AlipayConfig are readable at runtime (packaged as classpath resources or absolute paths present in the container).","Confirm you are using certificate mode consistently: appCertPath, alipayPublicCertPath, rootCertPath all set, and the keys match the open-platform app; use PKCS8 for RSA2.","Test the AlipayConfig by executing a trivial AlipayClient call in a unit test before wiring into AuthAlipayCertRequest."],"exampleFix":"// before\nnew AuthAlipayCertRequest(authConfig, alipayConfig); // cert paths missing in Docker -> AuthException(AlipayApiException)\n\n// after\n// load certs from classpath and verify before constructing\ntry (InputStream in = app.getResource(\"cert/appCertPublicKey.crt\").getInputStream()) {\n    Preconditions.checkNotNull(in, \"app cert missing\");\n}\nnew AuthAlipayCertRequest(authConfig, alipayConfig);","handlingStrategy":"validation","validationCode":"for (String p : new String[]{alipayConfig.getAppCertPath(), alipayConfig.getAlipayPublicCertPath(), alipayConfig.getRootCertPath()}) {\n    if (p == null || !new File(p).canRead()) throw new IllegalArgumentException(\"Alipay cert not readable: \" + p);\n}","typeGuard":null,"tryCatchPattern":"try { new AuthAlipayCertRequest(config, alipayConfig); } catch (AuthException e) { throw new ConfigurationException(\"Alipay client init failed: \" + (e.getCause() != null ? e.getCause().getMessage() : e.getMessage()), e); }","preventionTips":["Construct AuthAlipayCertRequest once at startup so cert errors surface at boot, not per login.","Package Alipay certs as versioned classpath resources.","Add a startup health check that executes a trivial AlipayClient call."],"tags":["justauth","alipay","certificate","sdk-init","config"],"backgroundTag":null,"analyzedSha":"694bbf1b010d93404e3bfb4824d90e9ddfaebebb","analyzedAt":"2026-08-14T15:16:59.945Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}