key cannot be loaded due to wrong format
Maintainers usually reply within 2 days
@eshentials is already working on this.
Since Sep 11, 2025.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 25/100
Research direction
Reproduce the Dockerfile's cfssl gencert flow using csr_timescaledb.json, csr_client.json, and cfssl-config.json, then inspect the generated key files and compare them with the OpenSSL setup linked in the issue. Check how the resulting certificates and keys are consumed by PostgreSQL; done means identifying whether cfssl produced an incompatible format or whether the PostgreSQL configuration is the cause.
Written by the indexing model from the issue text.
Description
Hi, I have the following Dockerfile to generate the certs:
FROM golang:1.20-alpine AS builder
RUN set -x && \
apk --no-cache add git gcc libc-dev make && \
# Create postgres user without specific GID/UID
addgroup postgres && \
adduser -S -G postgres postgres
RUN go install github.com/cloudflare/cfssl/cmd/...@latest
WORKDIR /app
COPY docker/volumes/timescaledb/certs/csr_timescaledb.json /app/csr_timescaledb.json
COPY docker/volumes/timescaledb/certs/csr_client.json /app/csr_client.json
COPY docker/volumes/timescaledb/certs/cfssl-config.json /app/cfssl-config.json
# Create directories for certificates
RUN mkdir -p /output && \
chown -R postgres:postgres /output
# Generate CA certificate
RUN cfssl gencert -initca /app/csr_timescaledb.json | cfssljson -bare ca
# Generate server certificate
RUN cfssl gencert \
-ca ca.pem \
-ca-key ca-key.pem \
-config=/app/cfssl-config.json \
/app/csr_timescaledb.json | cfssljson -bare server
# Generate client certificate
RUN cfssl gencert \
-ca ca.pem \
-ca-key ca-key.pem \
-config=/app/cfssl-config.json \
/app/csr_client.json | cfssljson -bare client
# Set proper permissions
RUN chmod 400 ca-key.pem server-key.pem client-key.pem && \
chmod 644 ca.pem server.pem client.pem
# Copy all certificates to output directory
RUN cp ca.pem client.pem client-key.pem server.pem server-key.pem /output/ && \
chmod 600 /output/client-key.pem /output/server-key.pem && \
chmod 644 /output/ca.pem /output/client.pem /output/server.pem && \
chown -R postgres:postgres /output
USER postgres
WORKDIR /app
CMD ["sh", "-c", "cp -v /output/* /certs-output/ && exit 0"]
compare to what I did with just openssl here: https://goteleport.com/blog/securing-postgres-postgresql/ I can make ssl to my postgres instance.
Did I do something wrong? or is there any reason why the format is wrong?
For more contex, I have put question in here: https://dba.stackexchange.com/questions/346355/running-postgresql-container-using-sslmode-verify-full-and-accessing-from-wsl-b?noredirect=1#comment672692_346355
- Dominant language
- Go
- Stars
- 9.5k
- Forks
- 1.2k
- Avg merge
- 5d 1h
- Merged PRs (30d)
- 5
Getting set up
- Ships a Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from cloudflare/cfssl
-
gencrl: serial numbers that fail to parse are added to the CRL as 0 or a partial valuePossibly taken @sebxt claimed this 3 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
cloudflare/cfssl#1460 ·
Maintainers usually reply within 2 days
-
crl_override (and extensions) in /api/v1/sign request body are silently ignored by the HTTP APIPossibly taken @Hashim1999164 claimed this 71 days ago. Open
Difficulty 2/5 Half a day Newbie friendliness 78/100
cloudflare/cfssl#1439 ·
Maintainers usually reply within 2 days
-
gencrl silently revokes the wrong serial number when a line is not plain decimalPossibly taken @RaphaelFakhri claimed this 4 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 30/100
cloudflare/cfssl#1458 ·
Maintainers usually reply within 2 days
-
config: LoadConfig panics when not_after is before not_beforePossibly taken @sebxt claimed this 5 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 25/100
cloudflare/cfssl#1456 ·
Maintainers usually reply within 2 days
-
Difficulty 3/5 1-2 days Newbie friendliness 48/100
cloudflare/cfssl#1446 ·
Maintainers usually reply within 2 days
All issues in cloudflare/cfssl
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
FiloSottile/age#758 ·
-
nginx configOpen
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
Maintainers usually reply within 2 days
-
fix: the buttons mock cannot take back the match point -- its undo looks only for the running matchOpenbug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
stuttgart-things/zaehlwerk#168 ·
Maintainers usually reply within 1 day