Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for NTS on the server #72

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,14 @@ following during startup:

> NTS-KE session with 164.67.62.194:4460 (tick.ucla.edu) timed out

To enable NTS within the chronyd server for clients, you can provide the path to an SSL certificate and matching private key (both in PEM format) with the `NTS_CRT` and `NTS_KEY` options, respectively:

```yaml
...
environment:
- NTS_CRT="/path/to/ssl.crt"
- NTS_KEY="/path/to/private.key"
```

## Testing your NTP Container

Expand Down
14 changes: 14 additions & 0 deletions assets/startup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,20 @@ for N in $NTP_SERVERS; do
fi
done

# Enable NTS server if vars present
if [ "${NTS_CRT:+1}${NTS_KEY:+1}" == 1 ]; then
# Only one variable was provided, when either both or none are required
# Exit with error due to invalid config
echo -e "ERROR: Both 'NTS_CRT' & 'NTS_KEY' are required vars when enabling NTS for chronyd. Currently have:\n* NTS_CRT=${NTS_CRT}\n* NTS_KEY=${NTS_KEY}"
exit 1
fi

if [ "${NTS_CRT:+1}${NTS_KEY:+1}" == 11 ]; then
# Both vars present, so inject into config
echo "ntsservercert ${NTS_CRT}" >> ${CHRONY_CONF_FILE}
echo "ntsserverkey ${NTS_KEY}" >> ${CHRONY_CONF_FILE}
fi

# final bits for the config file
{
echo
Expand Down
6 changes: 5 additions & 1 deletion vars
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ NTP_SERVERS="time.cloudflare.com"
# (optional) enable NTS in the chronyd configuration file
ENABLE_NTS=false

# (optional) provide SSL and key to enable NTS server in chronyd
NTS_CRT=""
NTS_KEY=""

# (optional) turn on noclientlog option
NOCLIENTLOG=false

Expand All @@ -25,4 +29,4 @@ NOCLIENTLOG=false
LOG_LEVEL=0

# (optional) additional docker run options you may want
DOCKER_OPTS=""
DOCKER_OPTS=""