Skip to content

Commit c0650e6

Browse files
Merge pull request #9990 from MxMurshed/uia/1112-add-support-for-self-signed-certificate
Add support for self signed certificate
2 parents 8baadf8 + fdd4208 commit c0650e6

File tree

1 file changed

+72
-5
lines changed

1 file changed

+72
-5
lines changed

content/en/docs/marketplace/platform-supported-content/services/private-service.md

Lines changed: 72 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,16 +62,19 @@ The following artifact is available for installing the service:
6262

6363
Follow these steps to install the service through Docker:
6464

65-
1. Pull the Docker image using the following command: `docker pull private-cloud.registry.mendix.com/mendix/document-generation-service:<tag>`.
66-
2. Run the Docker container using the following command: `docker run -p 8085:8085 --name document-generation private-cloud.registry.mendix.com/mendix/document-generation-service:<tag>`. This creates a Docker container, which is exposed on port `8085`.
65+
{{% alert color="info" %}}
66+
If you are using a self-signed certificate in your environment, skip these steps and refer to the [Importing a Self-Signed Certificate](#importing-a-self-signed-certificate) section.
67+
{{% /alert %}}
6768

68-
The `<tag>` component must be replaced with the version of the service, such as `1.0.0`. You can find all versions and their release notes in the [Private PDF Document Generation Service Release Notes](/releasenotes/marketplace/private-service/).
69+
1. Pull the Docker image using the following command: `docker pull private-cloud.registry.mendix.com/mendix/document-generation-service:latest`.
70+
2. Run the Docker container using the following command: `docker run -p 8085:8085 --name document-generation private-cloud.registry.mendix.com/mendix/document-generation-service:latest`. This creates a Docker container, which is exposed on port `8085`.
71+
72+
The `latest` tag allows you to use the most recent released version of the service. If you want to use a specific version, replace `latest` with the desired version, such as `1.0.0`. You can find all versions and their release notes in the [Private PDF Document Generation Service Release Notes](/releasenotes/marketplace/private-service/).
6973

7074
#### Setting Up a Health Check (Optional)
7175

7276
If you need to set up a health check, you can use the health check endpoint included in the service, at the `/health` path. This endpoint returns the `200` status code and the `OK` message if everything is working correctly.
7377

74-
7578
### Isolation
7679

7780
Requests share the same container resources, which has the following implications:
@@ -115,7 +118,71 @@ When using Docker to run the image, add the configuration using the provided env
115118
|----------------------|---------------|-------------|
116119
| `MAX_DOCUMENT_SIZE` | `25000000` (25 MB) | The maximum size for PDF documents generated using the service. When a PDF exceeds this file size, the request is aborted. |
117120
| `MAX_PAGE_RENDERING_TIME` | `30000` (30 seconds) | The maximum time to wait for the page to finish loading and rendering. If loading the page exceeds this time, a [Wait for Content](/appstore/modules/document-generation/#wait-for-content-exception) exception is sent to the module. |
118-
| `ACCEPT_INSECURE_CERTIFICATES` | `false` | <p> Allows the use of untrusted certificates, such as when using self-signed certificates.</p> <p> **Warning:** This disables certificate validation, and allows the use of invalid certificates. Be aware of any resulting security risks.</p> |
121+
| `ACCEPT_INSECURE_CERTIFICATES` | `false` | <p> Allows the use of untrusted certificates, such as when using self-signed certificates.</p> <p> **Warning:** This disables certificate validation, and allows the use of invalid certificates. Be aware of any resulting security risks. Alternatively, for better security, you can provide your certificates to the service. For details, refer to the [Importing a Self-Signed Certificate](#importing-a-self-signed-certificate) section.</p>|
122+
123+
### Importing a Self-Signed Certificate {#importing-a-self-signed-certificate}
124+
125+
If your environment uses a self-signed certificate, you can extend the PDF Document Generation service Docker image to trust this certificate. This is required for secure communication when the service needs to connect to endpoints using your custom Certificate Authority (CA).
126+
127+
Follow these steps:
128+
129+
1. Create a Docker file, such as `Dockerfile.import-cert`, with the following content:
130+
131+
```dockerfile
132+
FROM private-cloud.registry.mendix.com/mendix/document-generation-service:latest
133+
134+
ARG CERT_FILE_PATH
135+
136+
RUN echo "Check if CERT_FILE_PATH is provided"
137+
RUN if [ -z "$CERT_FILE_PATH" ]; then \
138+
echo "ERROR: CERT_FILE_PATH build argument is required"; \
139+
exit 1; \
140+
fi
141+
142+
RUN echo "Copy certificate as DocumentGeneration_CA"
143+
COPY ${CERT_FILE_PATH} /usr/local/share/ca-certificates/DocumentGeneration_CA.crt
144+
145+
USER root
146+
147+
RUN apk add nss-tools && update-ca-certificates
148+
149+
USER 1000
150+
151+
RUN mkdir -p "$HOME/.pki/nssdb"
152+
RUN certutil -d sql:$HOME/.pki/nssdb -N --empty-password
153+
154+
RUN echo "Add DocumentGeneration_CA to certificate store"
155+
RUN certutil -d sql:$HOME/.pki/nssdb -A -t "C,," -n "DocumentGeneration_CA" -i /usr/local/share/ca-certificates/DocumentGeneration_CA.crt
156+
157+
RUN echo "Verify certificate installation"
158+
RUN if certutil -d sql:$HOME/.pki/nssdb -L | grep -q "DocumentGeneration_CA"; then \
159+
echo "Certificate setup completed!"; \
160+
else \
161+
echo "ERROR: DocumentGeneration_CA not found in certificate store" && exit 1; \
162+
fi
163+
164+
WORKDIR /prod/docgen-worker-private
165+
166+
CMD [ "node", "bundle.js" ]
167+
```
168+
169+
1. Build the Docker image with your certificate:
170+
171+
```bash
172+
docker build -f Dockerfile.import-cert --build-arg CERT_FILE_PATH=<path-to-your-ca.crt> -t document-generation-service-with-cert .
173+
```
174+
175+
1. Run the container as usual:
176+
177+
```bash
178+
docker run -p 8085:8085 --name document-generation-service-with-cert
179+
```
180+
181+
Replace `<path-to-your-ca.crt>` with the path to your self-signed certificate's `.crt` or `.pem` file.
182+
183+
This approach ensures that the service trusts your self-signed certificate for secure connections.
184+
185+
If you only need the service to trust this self-signed certificate, Mendix recommends setting the `ACCEPT_INSECURE_CERTIFICATES` variable to `false`.
119186
120187
## Configuring your Mendix Apps
121188

0 commit comments

Comments
 (0)