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 self-signed certificates #324

Open
wants to merge 1 commit 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
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
config.yml
certs/README.md
4 changes: 4 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ FROM python:3.7-alpine
LABEL MAINTAINER="Daniel Pryor <[email protected]>"
LABEL NAME=vmware_exporter

# Install custom CA certificates, if any are given
COPY certs/* /usr/local/share/ca-certificates/
RUN update-ca-certificates

WORKDIR /opt/vmware_exporter/
COPY . /opt/vmware_exporter/

Expand Down
46 changes: 46 additions & 0 deletions certs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Custom CA certificates

Add your existing CA certificates encoded as PEM-certificates into this directory. They will be added to the trusted root certificates of the alpine linux base system and respected by the underlying python library used to connect to your VirtualCenter server.

## PEM encoded certificates
A PEM-encoded certificate file starts with

`-----BEGIN CERTIFICATE-----`

end ends with

`-----END CERTIFICATE-----`

## Usage
Store your custom root CA certificate into the `certs` folder. If you have a certificate chain, you will need to split the chain and store each certificate as a seperate file.

During `docker build` all files will be copied to `/usr/local/share/ca-certificates` and the command `update-ca-certificates` appends all certificates to the trusted root CA collection found at `/etc/ssl/certs/ca-certificates.crt`.

`update-ca-certificates` will ignore files containing more than one certificate, which is the reason for splitting chains into individual files.

## Certificate chain example
**Note:** The certificates will be deployed using `update-ca-certicates`. During this step, the file extension `.pem` will be added to all files. To avoid a duplicate `.pem.pem` file extension, the exemplary filenames shown below have been stripped from a file extension altogether. You can name the files to your liking, of course.

### root CA certificate
**Filename:** `YOUR_ORG-root`[.pem]

**Contents:**
```
-----BEGIN CERTIFICATE-----
BQAwgYwxCzAJBgNVBAYTAkRFMRswGQYDVQQIExJCYWRlbi1XdWVydHRlbWJlcmcx
...
2uvOgYT/kkhCBM2fKS0domiDJE5iRrKzGOOQoh82Ya2P2epK6oHnaj6Zn+18o4k2
-----END CERTIFICATE-----
```

### Intermediate CA certificate
**Filename:** `YOUR_ORG-intermediate`[.pem]

**Contents:**
```
-----BEGIN CERTIFICATE-----
cnQxEjAQBgNVBAoTCXNod2lsbC5pbzEUMBIGA1UECxMLQ0EgU2VydmljZXMxIjAg
...
+L9xUQZlXZeEyGmtwY5dyckDuRcUCYUZQAjR0MhSR4wZaCYyc+gnv6Mc6kJS6bCz
-----END CERTIFICATE-----
```