Skip to content

TLS cert caching error #407

@cuchaz

Description

@cuchaz

Hello again,

I diagnosed an issue with Ferron today where the cached TLS certificate files became corrupted somehow. All of the certificate_xxxx files in folders with similar random-looking names appear to be ASCII-armored certificates serialized in a JSON format. But today, after doing a server reboot, Ferron failed to start because the JSON files had "trailing characters". The error log for Ferron had a message like this:

Error while obtaining a TLS certificate: trailing characters at line 1 column 3200

I went and inspected the files and indeed, they did have extra characters after the closure of the last JSON object. Those extra characters looked like more JSON syntax, but it was somehow out of sync with the rest of the contents of the file, which was otherwise valid JSON. Removing the trailing characters and restarting Ferron fixed the issue.

I don't know exactly how to reproduce the file corruption, but I suspect somewhere the JSON file was overwritten by Ferron without truncating the old one. Maybe a certificate refresh caused Ferron to update the cached file, and by luck, the new serialized data was smaller than the old data, so not all of the file was overwritten. I think changing the file open flags for cache file writes might fix the issue?

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions