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

docker_api https fix for secured docker #673

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 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 app/functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,14 @@ function docker_api {
else
scheme="http://${DOCKER_HOST#*://}"
fi

if [[ -v DOCKER_TLS_VERIFY && -v DOCKER_CERT_PATH && ! -z "$DOCKER_TLS_VERIFY" ]]; then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the sake of consistency with the other features, could we check if DOCKER_TLS_VERIFY is set to true/True/TRUE (using the lc() function) instead of just setting the variable to any value ?

curl_opts+=(--cert ${DOCKER_CERT_PATH}/cert.pem)
curl_opts+=(--key ${DOCKER_CERT_PATH}/key.pem)
curl_opts+=(--cacert ${DOCKER_CERT_PATH}/ca.pem)
scheme="https://${DOCKER_HOST#*://}"
fi

[[ $method = "POST" ]] && curl_opts+=(-H 'Content-Type: application/json')
curl "${curl_opts[@]}" -X "${method}" "${scheme}$1"
}
Expand Down
8 changes: 8 additions & 0 deletions docs/Container-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,11 @@ You can also create test certificates per container (see [Test certificates](./L
* `REUSE_PRIVATE_KEYS` - Set it to `true` to make `simp_le` reuse previously generated private key for each certificate instead of creating a new one on certificate renewal. Recommended if you intend to use [HPKP](https://developer.mozilla.org/en-US/docs/Web/HTTP/Public_Key_Pinning) (please not however that HPKP has been deprecated by Google's Chrome and that its use is therefore not recommended).

* `DHPARAM_BITS` - Change the size of the Diffie-Hellman key generated by the container from the default value of 2048 bits. For example `--env DHPARAM_BITS=1024` to support some older clients like Java 6 and 7.

## Optional docker host configuration
* `DOCKER_HOST` - set the host for docker. Must include the scheme (`unix://`, `http://` or `https://`)

If the docker host daemon socket is [protected](https://docs.docker.com/engine/security/https/):

* `DOCKER_TLS_VERIFY` - set it to value `1` if the docker host requires client TLS authentication
* `DOCKER_CERT_PATH` - path to TLS client certificates for the docker host. This folder should contain `cert.pem`, `key.pem` and `ca.pem` files. See [Create a CA, server and client keys with OpenSSL](https://docs.docker.com/engine/security/https/#create-a-ca-server-and-client-keys-with-openssl)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should be a bit more clearer about the fact that this environment variable set a path that will be looked upon inside the container and that the expected file will have to be mounted to this path somehow.