Skip to content

Commit 1d91dea

Browse files
Add support for custom certificates to Docker (llvm-ml#19)
* Add support for custom certificates to Docker This commit adds in support for using custom certificates in the standalone Docker container along with changing some SSL settings so that the build/container works in environments that are firewalled/have custom SSL certificates. * Add documentation about new flags to the README * Add example of building a container image based on the changes in this PR
1 parent 0fd9ddb commit 1d91dea

File tree

3 files changed

+49
-0
lines changed

3 files changed

+49
-0
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
__pycache__
2+
*.crt

.packaging/Dockerfile

+12
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,30 @@ ARG UBUNTU_VERSION=22.04
22
ARG LLVM_VERSION=16
33
ARG JULIA_MAJOR_VERSION=8
44
ARG JULIA_MINOR_VERSION=3
5+
ARG CUSTOM_CERT
6+
ARG ENABLE_LEGACY_RENEGOTIATION
57

68
FROM ubuntu:$UBUNTU_VERSION
79

810
ARG LLVM_VERSION
911
ARG JULIA_MAJOR_VERSION
1012
ARG JULIA_MINOR_VERSION
13+
ARG CUSTOM_CERT
14+
ARG ENABLE_LEGACY_RENEGOTIATION
1115

1216
ENV DEBIAN_FRONTEND=noninteractive
1317

1418
# Install the base dependencies
1519
RUN apt-get update && apt-get install -y --no-install-recommends python3 python-is-python3 wget curl lsb-release ca-certificates software-properties-common build-essential gnupg2 python3-pip git pkg-config libssl-dev gcc gfortran
1620

21+
# Setup a custom certificate/SSL settings depending upon build arguments
22+
# Include README.md here so that the build doesn't fail if there is no custom
23+
# certificate specified. Then we just delete it afterwards.
24+
COPY README.md $CUSTOM_CERT /usr/local/share/ca-certificates/
25+
RUN rm /usr/local/share/ca-certificates/README.md \
26+
&& update-ca-certificates
27+
RUN if [ -n "$ENABLE_LEGACY_RENEGOTIATION" ]; then echo "Options = UnsafeLegacyRenegotiation" >> /etc/ssl/openssl.cnf ; fi
28+
1729
# Can this be converted into a native Ubuntu install as in the LLVM case
1830
ENV CARGO_HOME="/cargo"
1931
ENV RUSTUP_HOME="/rustup"

.packaging/README.md

+36
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,39 @@ repository:
1111
```bash
1212
docker build -t llvm-ir-dataset-utils -f ./.packaging/Dockerfile .
1313
```
14+
15+
To get the image building on machines where an older firewall or custom SSL
16+
certificates are used, you can pass the following two build arguments to
17+
the Docker build to make the image build work in your environment:
18+
19+
* `CUSTOM_CERT` - Pass the path to a `*.crt` file in the build context to make
20+
the container use the certificate. Note that the file extension must be `*.crt`
21+
and not `*.pem` or something else due to how Ubuntu's `update-ca-certificates`
22+
detects new certificates.
23+
* `ENABLE_LEGACY_RENEGOTIATION` - Enables legacy renegotiation which is a
24+
problem on some systems that have a firewall in place when accessing certain
25+
hosts.
26+
27+
As an example, to build a container in an environment that doesn't support SSL
28+
renegotiation and with a custom certificate, you can run the following commands:
29+
30+
1. Start by making sure your current working directory is the root of the
31+
project:
32+
```bash
33+
cd /path/to/llvm-ir-dataset-utils
34+
```
35+
2. Copy over the certificate (bundle) that you want the container to use:
36+
```bash
37+
cp /path/to/certificate.crt ./additional_cert.crt
38+
```
39+
3. Build the container image, making sure to specify the appropriate build
40+
flags:
41+
```bash
42+
docker build \
43+
-t llvm-ir-dataset-utils \
44+
-f ./.packaging/Dockerfile \
45+
--build-arg="CUSTOM_CERT=./additional_cert.crt" \
46+
--build-arg="ENABLE_LEGACY_RENEGOTIATION=ON"
47+
```
48+
49+
Then you should end up with the desired container image.

0 commit comments

Comments
 (0)