Skip to content

Conversation

Copy link

Copilot AI commented Oct 9, 2025

This PR adds support for importing SSL certificates generated by Caddy Server into UniFi OS Server, addressing issue requirements to use existing Caddy-generated certificates without needing to generate new ones.

Changes Made

Script Updates

  • Added caddy as a supported certificate provider alongside existing certbot and acme options
  • Implemented Caddy certificate directory resolution for the standard path: /var/lib/caddy/.local/share/caddy/certificates/acme-v02.api.letsencrypt.org-directory/{domain}/
  • Added support for Caddy's certificate file naming convention ({domain}.crt and {domain}.key)
  • Updated validation logic to check for Caddy data directory existence
  • Enhanced certificate installation logic to handle Caddy's full-chain certificate format
  • Updated help text and error messages to include Caddy option

Documentation Updates

  • Added comprehensive Caddy support section to README.md with prerequisites and configuration examples
  • Updated all command-line examples to demonstrate Caddy usage
  • Added Caddy-specific automation examples for crontab setup
  • Updated feature list and provider options throughout documentation

Usage

Basic Usage

# Import existing Caddy certificates
./unifi-osserver-ssl-import.sh --provider=caddy

# With verbose output for troubleshooting
./unifi-osserver-ssl-import.sh --provider=caddy --verbose

Automation

# Auto-import Caddy certificates twice daily
5 */12 * * * root /usr/local/bin/unifi-osserver-ssl-import.sh --provider=caddy >> /home/import_log.txt 2>&1

Prerequisites

  • Caddy server must be installed and configured
  • Caddy must have already generated certificates for your domain
  • Certificates should exist at the expected Caddy path structure

Testing

The implementation has been thoroughly tested with:

  • Mock certificate directory structure validation
  • Error handling for missing certificate directories
  • Shell script linting (shellcheck)
  • Command-line argument parsing verification

This change maintains full backward compatibility with existing certbot and acme providers while adding seamless Caddy integration.

Original prompt

This section details on the original issue you should resolve

<issue_title>Add Caddy import support</issue_title>
<issue_description>We have an SSL certificate generated by https://caddyserver.com/ located at /var/lib/caddy/.local/share/caddy/certificates/acme-v02.api.letsencrypt.org-directory/unifios.synergi.tech/

We need to add support for this to be imported into unifi os. Modify the existing .sh file to add Caddy support. We should not need to generate new SSL certificates; we only need to import the new ones, as Caddy handles generation.</issue_description>

Comments on the Issue (you are @copilot in this section)

Fixes #1

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: MattHadfield113 <30897252+MattHadfield113@users.noreply.github.com>
Copilot AI changed the title [WIP] Add Caddy import support for SSL certificates Add Caddy import support Oct 9, 2025
Copilot AI requested a review from MattHadfield113 October 9, 2025 10:11
Copilot finished work on behalf of MattHadfield113 October 9, 2025 10:11
@willpower232
Copy link
Member

I'd probably reduce the automation to 5 */12 * * * root /usr/local/bin/unifi-osserver-ssl-import.sh --provider=caddy so there isn't one giant log file but sure

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.

Add Caddy import support

3 participants