{"record":{"id":"1f05af2d2c0e3901","repo":"t8y2/dbx","slug":"failed-to-configure-tls-e-getmessage","errorCode":null,"errorMessage":"Failed to configure TLS: ${e.getMessage()}","messagePattern":"Failed to configure TLS: (.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"agents/drivers/mongodb/src/main/java/com/dbx/agent/mongodb/MongoAgent.java","lineNumber":172,"sourceCode":"        return client;\n    }\n\n    private static Object connect(JsonObject params) {\n        closeLegacyClient();\n        legacyClient = openClient(params);\n        return Collections.singletonMap(\"ok\", true);\n    }\n\n    private static void applyTlsSettings(MongoClientSettings.Builder builder,\n        String caCertPath, String clientCertPath, String clientKeyPath) {\n        builder.applyToSslSettings(sslBuilder -> {\n            sslBuilder.enabled(true);\n            if (caCertPath != null && !caCertPath.isBlank()\n                || clientCertPath != null && !clientCertPath.isBlank()) {\n                try {\n                    sslBuilder.context(createTlsSslContext(caCertPath, clientCertPath, clientKeyPath));\n                } catch (Exception e) {\n                    throw new RuntimeException(\"Failed to configure TLS: \" + e.getMessage(), e);\n                }\n            }\n        });\n    }\n\n    static SSLContext createTlsSslContext(String caCertPath, String clientCertPath, String clientKeyPath)\n        throws Exception {\n        TrustManager[] trustManagers = null;\n        if (caCertPath != null && !caCertPath.isBlank()) {\n            trustManagers = loadTrustManagersFromPem(caCertPath);\n        }\n\n        KeyManager[] keyManagers = null;\n        if (clientCertPath != null && !clientCertPath.isBlank()\n            && clientKeyPath != null && !clientKeyPath.isBlank()) {\n            keyManagers = loadKeyManagersFromPem(clientCertPath, clientKeyPath);\n        }\n","sourceCodeStart":154,"sourceCodeEnd":190,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/agents/drivers/mongodb/src/main/java/com/dbx/agent/mongodb/MongoAgent.java#L154-L190","documentation":"Thrown by MongoAgent.applyTlsSettings while enabling TLS on the MongoClientSettings builder — typically when loading/parsing the CA certificate or client certificate/key files referenced by the TLS connection parameters. The underlying exception message (e.getMessage()) is embedded; the failure means the driver could not build the SSL context, so client construction aborts.","triggerScenarios":"Thrown at agents/drivers/mongodb/src/main/java/com/dbx/agent/mongodb/MongoAgent.java:172 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check the embedded cause message: file-not-found usually means the ca/client certificate paths are wrong on the agent host","Verify certificate and key files are valid PEM and readable by the agent process","For client certificates confirm the key is PKCS#8 or PKCS#1 PEM as required by loadPrivateKeyFromPem","If TLS is not actually required, remove the TLS-related connection parameters"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"c0390bff16418b651f4728520d99adf8ce48829a","analyzedAt":"2026-09-05T23:05:10.900Z","contentChangedAt":"2026-09-05T23:05:10.900Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}