-
When running custom dockerfile FROM node:20.11.1-alpine3.19
# Add our local certificate to the trusted store
# COPY src-root.crt /usr/local/share/ca-certificates/
COPY src-sub.crt /usr/local/share/ca-certificates/
COPY git-csm.example.com.crt /usr/local/share/ca-certificates/
# Update the trusted store (https://stackoverflow.com/a/67232164)
# RUN cat /usr/local/share/ca-certificates/src-root.crt >> /etc/ssl/certs/ca-certificates.crt && \
RUN cat /usr/local/share/ca-certificates/src-sub.crt >> /etc/ssl/certs/ca-certificates.crt && \
cat /usr/local/share/ca-certificates/git-csm.example.com.crt >> /etc/ssl/certs/ca-certificates.crt && \
apk --no-cache add curl git
# Setup node variables to respect the trusted store
ENV NODE_EXTRA_CA_CERTS=/usr/local/share/ca-certificates/git-csm.example.com.crt
ENV NODE_OPTIONS=--use-openssl-ca Inside the image curl works normally (cert is correctly added to the local store)
But using the following code: const axios = require('axios');
axios.get('https://git-csm.example.com')
.then(response => {
console.log('Status Code:', response.status);
console.log('Body:', response.data);
})
.catch(error => {
console.error('Error:', error);
}); I ran into the error
Any ideas what am I doing wrong? |
Beta Was this translation helpful? Give feedback.
Answered by
bl4ko
Sep 12, 2024
Replies: 1 comment
-
Fixed by including full certificate chain instead of only providing sub.crt or root.crt. |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
bl4ko
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Fixed by including full certificate chain instead of only providing sub.crt or root.crt.