Skip to content

Conversation

@brunato
Copy link

@brunato brunato commented Dec 4, 2025

The new feature is a new configuration option for automatic naming of key/csr/crt files. With the current changes the new configuration in applicable to request and download commands. If the option is not configured or a custom output-filename is provided the outputh filepath is obtained with a join on output_folder, as before.

The new config option output_template is a template string that can be used for organizing certificate files in subfolders and/or to add date stamps on saved files in order to maintain a repository with many certificates and along time. I tried to keep the previous behavior if the configuration is not added.

If the feature is of some interest I could keep working on applying the new configuration to other commands (smime) and add other tests for commands before the merge.

I've also added an argument to main() in order to simplify the tests on various commands.

Other ideas that could be interesting in order to extend the tool is the option of make the package/commands importable by a module and reorganizing fatal errors (exit(1)) with a custom exception that is intercepted by main.

thanks

Davide

Apply new configuration option to request and download commands.
If the option is not configured or a custom output-filename is
provided the outputh filepath is obtained with a join on output_folder,
as before.
@brunato
Copy link
Author

brunato commented Dec 4, 2025

The template is processed using a derived class OutputTemplate that is defined in utils.py module. This class has an additional method get_filepath that processes the provided filename and builds a template map used to get the effective filepath for saving the file.

For example, setting output_template = ${fqdn}/${fqdn}${suffix} a filename foo.bar.test.key is mapped to foo.bar.test/foo.bar.test.key and the full path will be ~/harica_certificates/foo.bar.test/foo.bar.test.key.

Also identifiers based on dates can be expressed within the template string. For example setting output_template = ${year}${month}${day}/${fqdn}${suffix} the filename foo.bar.test_fullchain.pem will be mapped to ~/harica_certificates/20251204/foo.bar.test_fullchain.pem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant