{"record":{"id":"f9b13a09f280fcef","repo":"quarkusio/quarkus","slug":"unable-to-read-the-account-file-you-must-create-a","errorCode":null,"errorMessage":"Unable to read the account file, you must create account first","messagePattern":"Unable to read the account file, you must create account first","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"extensions/tls-registry/cli/src/main/java/io/quarkus/tls/cli/letsencrypt/LetsEncryptHelpers.java","lineNumber":249,"sourceCode":"\n            builder.setKey(certificate, privateKey);\n        }\n\n        AcmeAccount acmeAccount = builder.build();\n\n        acmeAccount.setContactUrls(new String[] { json.getString(\"contact-url\") });\n        acmeAccount.setAccountUrl(json.getString(\"account-url\"));\n\n        return acmeAccount;\n    }\n\n    private static JsonObject readAccountJson(File letsEncryptPath) {\n        LOGGER.debugf(\"Reading account information from %s\", letsEncryptPath);\n        java.nio.file.Path accountPath = Paths.get(letsEncryptPath + \"/account.json\");\n        try (FileInputStream fis = new FileInputStream(accountPath.toString())) {\n            return new JsonObject(new String(fis.readAllBytes(), StandardCharsets.US_ASCII));\n        } catch (IOException e) {\n            throw new RuntimeException(\"Unable to read the account file, you must create account first\");\n        }\n    }\n\n    private static X509Certificate getCertificate(String encodedCert) {\n        try {\n            byte[] encodedBytes = Base64.getDecoder().decode(encodedCert);\n            return (X509Certificate) CertificateFactory.getInstance(\"X.509\")\n                    .generateCertificate(new ByteArrayInputStream(encodedBytes));\n        } catch (Exception ex) {\n            throw new RuntimeException(\"Failure to create a certificate\", ex);\n        }\n    }\n\n    private static PrivateKey getPrivateKey(String encodedKey, String keyAlgorithm) {\n        try {\n            KeyFactory f = KeyFactory.getInstance((keyAlgorithm == null || \"RSA\".equals(keyAlgorithm) ? \"RSA\" : \"EC\"));\n            byte[] encodedBytes = Base64.getDecoder().decode(encodedKey);\n            PKCS8EncodedKeySpec spec = new PKCS8EncodedKeySpec(encodedBytes);","sourceCodeStart":231,"sourceCodeEnd":267,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/tls-registry/cli/src/main/java/io/quarkus/tls/cli/letsencrypt/LetsEncryptHelpers.java#L231-L267","documentation":"readAccountJson reads <letsEncryptPath>/account.json, which saveAccount writes during account creation. If the file cannot be opened or read (typically because it does not exist), this RuntimeException tells the user they must run account creation first. No underlying exception is chained; the message is the entire diagnostic.","triggerScenarios":"Calling the json() method (or any flow calling readAccountJson) before createAccount has ever run, or pointing at a letsEncryptPath directory that contains no account.json.","commonSituations":"Running 'renew' or account-inspection commands on a fresh machine/checkout without 'create account' first; mistyped or changed letsencrypt directory path; account.json deleted by cleanup scripts or container restarts on ephemeral storage.","solutions":["Create the ACME account first (run the create-account command / LetsEncryptHelpers.createAccount) so account.json is written","Verify letsEncryptPath points to the directory that actually contains account.json","Check file permissions so the current user can read account.json","If the account was stored on ephemeral storage (container), persist the letsencrypt directory as a volume"],"exampleFix":"// before: reading account before it exists\nJsonObject json = LetsEncryptHelpers.json(new File(\"/etc/quarkus/letsencrypt\")); // RuntimeException\n// after: create the account first\nLetsEncryptHelpers.createAccount(acmeClient, new File(\"/etc/quarkus/letsencrypt\"), true, \"my@example.com\");\nJsonObject json = LetsEncryptHelpers.json(new File(\"/etc/quarkus/letsencrypt\"));","handlingStrategy":"validation","validationCode":"File dir = letsEncryptPath;\nFile accountFile = new File(dir, \"account.json\");\nif (!accountFile.isFile() || !accountFile.canRead()) {\n    throw new IllegalStateException(\"ACME account not found at \" + accountFile + \"; create the account first\");\n}\nJsonObject json = LetsEncryptHelpers.json(dir);","typeGuard":"boolean hasAcmeAccount(File letsEncryptPath) {\n    File f = new File(letsEncryptPath, \"account.json\");\n    return f.isFile() && f.canRead() && f.length() > 0;\n}","tryCatchPattern":"try {\n    JsonObject json = LetsEncryptHelpers.json(letsEncryptPath);\n} catch (RuntimeException e) {\n    if (e.getMessage() != null && e.getMessage().contains(\"Unable to read the account file\")) {\n        // account was never created or path is wrong — run account creation flow\n        throw new IllegalStateException(\"No ACME account at \" + letsEncryptPath + \"/account.json. Run create-account first.\", e);\n    }\n    throw e;\n}","preventionTips":["Always run account creation before renewal/lookup commands","Persist the letsencrypt directory across container restarts (volume mount)","Verify the letsEncryptPath matches the one used at account creation","Check account.json readability after deployments or permission changes"],"tags":["acme","letsencrypt","io","missing-file"],"backgroundTag":"missing-file-not-found","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}