feat: docker trusted CA Certificate updating #35

Merged
jon_nfc merged 3 commits from 17-docker-custome-ca-certs into development 2024-02-26 07:06:22 +00:00
8 changed files with 65 additions and 5 deletions
Showing only changes of commit 3b6f236602 - Show all commits

View File

@ -109,6 +109,7 @@ RUN mkdir -p /tmp/collection; \
rm -Rf /tmp/collection; \
fi; \
chmod +x /etc/cron.d/*; \
chmod +x /bin/update-ca; \
chown root:root -R /etc/phpipam; \
chmod 740 -R /etc/phpipam;

View File

@ -22,6 +22,7 @@ docker run \
-p "5000:5000" \
-v "./scan_agent.yaml:/etc/phpipam/scan_agent.yaml" \
-v "./scan_server.yaml:/etc/phpipam/scan_server.yaml" \
-v "./my-custom-ca.crt:/usr/local/share/ca-certificates/my-custom-ca.crt:ro"
--name scan-agent \
nofusscomputing/phpipam-scan-agent:latest;
@ -37,9 +38,16 @@ When viewing the container logs `docker logs <container name>`, what you will se
During the build of the container environmental variable `ANSIBLE_FORCE_COLOR='true'` is set, this enables the playbooks to be in colour when viewing the container logs. If this is not desired, set the variable to `ANSIBLE_FORCE_COLOR='false'` when launching the container.
### Custom CA Certificate
When the container starts or restarts a script runs that updates the containers trusted CA certificates. Details for mounting a/an certificate(s) is detailed below.
### Volumes
You will need to configure the scan components:
To configure the components, the following files will need to be mounted within the container:
- Custom CA certificate at path `/usr/local/share/ca-certificates/`. you can mount a single `crt` file or multiple if you use a sub-directory at this path.
- scanner config file at path `/etc/phpipam/scan_agent.yaml`, see [scanner docs](scanner.md#variables) for details.

View File

@ -54,7 +54,7 @@ The following features are available or planned to be implmented:
- [Remote Network Scanning](scanner.md#remote-network-scannning)
- [Resolve DNS names](index.md#Resolve-dns-names)
- [Resolve DNS names](index.md#resolve-dns-names)
- [Timezone Normalization](server.md#timezone-normalization)

View File

@ -100,7 +100,7 @@ The scanner component has the following workflow:
Once the [server component](server.md#remote-network-scannning) has been setup, the client can be installed/used from any network. Even a network that is isolated from the server. Only caveat is that the client can communicate with the server. To ensure that the client can connect to the server set the `auth_token` to match that of the server.
There is no true confirmation of the servers identity outside of confirming the TLS Certificate is trusted. Due to this fact, you're advised to use your own CA to sign the server components TLS Certificate. By doing this only you can issue a certificate to the server component. All that is required is to ensure that your CA certificate is within the trusted certificates of the machine that is running the agent.
There is no true confirmation of the servers identity outside of confirming the TLS Certificate is trusted. Due to this fact, you're advised to use your own CA to sign the server components TLS Certificate. By doing this only you can issue a certificate to the server component. All that is required is to ensure that [your CA certificate](docker.md#custom-ca-certificate) is within the [trusted certificates](../../../itil/runbooks/linux/custom_ca.md) of the machine that is running the agent.
!!! danger "Security"
Failing to secure the server component communication with TLS will allow anyone with direct access to the line of communication to view the `auth_token`. Anyone who has the `auth_token` will be able to upload data to the server.

View File

@ -61,7 +61,7 @@ The Server componet has the following workflow:
## Remote network Scannning
Remote network scanning is possible with the Scan-Agent. The server must be setup and have connectivity to the phpIPAM MariaDB/MySQL database. Currently the server does not perform secure communication. As such you are strongly encouraged to setup the server component behind a reverse proxy that conducts the TLS termination.
Remote network scanning is possible with the Scan-Agent. The server must be setup and have connectivity to the phpIPAM MariaDB/MySQL database. Currently the server does not perform secure communication. As such you are strongly encouraged to setup the server component behind a reverse proxy that conducts the TLS termination. It's also recommended that you use your [own CA](docker.md#custom-ca-certificate) to sign the TLS certificate. Just don't forget to add this CA certificate to the [trusted CA certificates](../../../itil/runbooks/linux/custom_ca.md)
The [scan](scanner.md#remote-network-scannning) and server component must be setup with the same `auth_token`. It is this token that provides a means to ensure that what the server is receiving, is from an authorized client.

View File

@ -0,0 +1 @@
linked page

40
includes/bin/update-ca Executable file
View File

@ -0,0 +1,40 @@
#!/bin/sh
set -e;
run_command() {
command_date=$(date '+%Y-%m-%d %H:%M:%S');
echo "${command_date} - info - $1 - $2";
$1
if [ $? ]; then
echo "${command_date} - info - $1 - command ran without error. exit=$?";
else
echo "${command_date} - error - ${1} - command had an error. exit=$?";
fi
}
while :
do
run_command "ls -lR /usr/local/share/ca-certificates/" "List custom CA Certificates";
run_command "update-ca-certificates --fresh" "Clear currently trusted CA Certificates";
run_command "update-ca-certificates" "Update trusted CA Certificates";
sleep 9999999999999;
done;

View File

@ -0,0 +1,8 @@
[program:trusted-ca-update]
startsecs=0
stopwaitsecs=55
command=/bin/update-ca
autorestart=true
autostart=true
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0