You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This repository contains scripts to automate deployment of a TLS certificate to your FreeNAS (11.1 or newer) or TrueNAS server. Due to a complete overhaul of the API in more recent versions of TrueNAS, this repo contains two different scripts, each with its own README.
3
+
4
+
* If you're using FreeNAS, or TrueNAS CORE, use `deploy_freenas.py`. [README](README_freenas.md). This will also work with TrueNAS SCALE through 24.10, but as SCALE introduced a websocket API, the other script is recommended.
5
+
* If you're using TrueNAS SCALE or Community Edition (as of 25.04), use `deploy_truenas.py`. [README](README_truenas.md)
6
+
* I've had no reports of compatibility, pro or con, with any version of TrueNAS Enterprise. I expect the `_freenas` version will work with FreeBSD-based TrueNAS Enterprise installations, while the `_truenas` version will work with Linux-based installations, but I'm afraid you're largely on your own.
deploy_freenas.py is a Python script to deploy TLS certificates to a FreeNAS/TrueNAS (Core) server using the FreeNAS/TrueNAS API. This should ensure that the certificate data is properly stored in the configuration database, and that all appropriate services use this certificate. Its original intent was to be called from a Let's Encrypt client like [acme.sh](https://github.com/Neilpang/acme.sh) after the certificate is issued, so that the entire process of issuance (or renewal) and deployment can be automated. However, it can be used with certificates from any source, whether a different ACME-based certificate authority or otherwise.
4
+
5
+
Since this script was developed, acme.sh has added a [deployment script](https://github.com/acmesh-official/acme.sh/wiki/deployhooks#25-deploy-the-cert-on-truenas-core-server) which can deploy newly-issued certs to your TrueNAS system, so you may not need this script. However, it isn't clear whether the acme.sh deployment script handles the services covered by this script (S3, FTP, WebDAV, Apps for SCALE).
6
+
7
+
# Installation
8
+
This script can run on any machine running Python 3 that has network access to your FreeNAS/TrueNAS server, but in most cases it's best to run it directly on the FreeNAS/TrueNAS box. Change to a convenient directory and run `git clone https://github.com/danb35/deploy-freenas`.
9
+
10
+
If you're not running this script on your Free/TrueNAS server itself, you'll need to make sure that the Python `requests` module is available (it's there by default in Free/TrueNAS). How you'll do that will depend on the OS you're using wherever you're running the script.
11
+
12
+
# Usage
13
+
14
+
The relevant configuration takes place in the `deploy_config` file. You can create this file either by copying `deploy_config_freenas.example` from this repository, or directly using your preferred text editor. Its format is as follows:
15
+
16
+
```
17
+
[deploy]
18
+
password = YourReallySecureRootPassword
19
+
cert_fqdn = foo.bar.baz
20
+
connect_host = baz.bar.foo
21
+
verify = false
22
+
privkey_path = /some/other/path
23
+
fullchain_path = /some/other/other/path
24
+
protocol = https://
25
+
port = 443
26
+
ui_certificate_enabled = false
27
+
s3_enabled = false
28
+
ftp_enabled = false
29
+
webdav_enabled = false
30
+
apps_enabled = false
31
+
apps_only_matching_san = false
32
+
cert_base_name = letsencrypt
33
+
```
34
+
35
+
Everything but `password` (or `api_key`) is optional, and the defaults are documented in `deploy_config.example`.
36
+
37
+
On TrueNAS (Core) 12.0 and up you should use API key authentication instead of password authentication.
38
+
[Generate a new API token in the UI](https://www.truenas.com/docs/hub/additional-topics/api/#creating-api-keys) first, then add it as `api_key` to the config, which replaces the `password` field:
Once you've prepared `deploy_config`, you can run `deploy_freenas.py`. The intended use is that it would be called by your ACME client after issuing a certificate. With acme.sh, for example, you'd add `--reloadcmd "/path/to/deploy_freenas.py"` to your command.
44
+
45
+
There is an optional paramter, `-c` or `--config`, that lets you specify the path to your configuration file. By default the script will try to use `deploy_config` in the script working directoy:
Copy file name to clipboardExpand all lines: README_truenas.md
+5-5
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,8 @@
1
1
# deploy-freenas
2
2
3
-
deploy-freenas.py is a Python script to deploy TLS certificates to a TrueNAS SCALE server using the TrueNAS Websocket API. This should ensure that the certificate data is properly stored in the configuration database, and that all appropriate services use this certificate. Its original intent was to be called from an ACME client like [acme.sh](https://github.com/acmesh-official/acme.sh) after the certificate is issued, so that the entire process of issuance (or renewal) and deployment can be automated. However, it can be used with certificates from any source, whether a different ACME-based certificate authority or otherwise.
3
+
deploy_truenas.py is a Python script to deploy TLS certificates to a TrueNAS SCALE/Community Edition server using the TrueNAS Websocket API. This should ensure that the certificate data is properly stored in the configuration database, and that all appropriate services use this certificate. Its original intent was to be called from an ACME client like [acme.sh](https://github.com/acmesh-official/acme.sh) after the certificate is issued, so that the entire process of issuance (or renewal) and deployment can be automated. However, it can be used with certificates from any source, whether a different ACME-based certificate authority or otherwise.
4
4
5
-
Since this script was developed, acme.sh has added a [deployment script](https://github.com/acmesh-official/acme.sh/wiki/deployhooks#25-deploy-the-cert-on-truenas-core-server) which can deploy newly-issued certs to your TrueNAS system, so you may not need this script. However, it isn't clear whether the acme.sh deployment script handles the services covered by this script (S3, FTP, WebDAV, Apps for SCALE).
5
+
Since this script was developed, acme.sh has added a [deployment script](https://github.com/acmesh-official/acme.sh/wiki/deployhooks#25-deploy-the-cert-on-truenas-core-server) which can deploy newly-issued certs to your TrueNAS system, so you may not need this script. However, it isn't clear whether the acme.sh deployment script handles the services covered by this script (S3, FTP, WebDAV, Apps for SCALE).`acme.sh` also has a separate deployment script for the websocket API, but again, its capabilities compared to this one are unknown.
6
6
7
7
# WORK IN PROGRESS
8
8
This version of this script is a work in progress, and has had minimal testing.
@@ -37,7 +37,7 @@ Then clone this repository as described above. Your system should be prepared t
37
37
38
38
# Usage
39
39
40
-
The relevant configuration takes place in the `deploy_config` file. You can create this file either by copying `deploy_config.example` from this repository, or directly using your preferred text editor. Its format is as follows:
40
+
The relevant configuration takes place in the `deploy_config` file. You can create this file either by copying `deploy_config_truenas.example` from this repository, or directly using your preferred text editor. Its format is as follows:
41
41
42
42
```
43
43
[deploy]
@@ -60,10 +60,10 @@ An API key is required for authentication. [Generate a new API token in the UI]
Once you've prepared `deploy_config`, you can run `deploy_freenas.py`. The intended use is that it would be called by your ACME client after issuing a certificate. With acme.sh, for example, you'd add `--reloadcmd "/path/to/deploy_freenas.py"` to your command.
63
+
Once you've prepared `deploy_config`, you can run `deploy_truenas.py`. The intended use is that it would be called by your ACME client after issuing a certificate. With acme.sh, for example, you'd add `--reloadcmd "/path/to/deploy_truenas.py"` to your command.
64
64
65
65
There is an optional paramter, `-c` or `--config`, that lets you specify the path to your configuration file. By default the script will try to use `deploy_config` in the script working directoy:
0 commit comments