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

fix cacert() to work with openssl's defaults #71

Merged
merged 2 commits into from
Aug 21, 2024

Conversation

lazcamus
Copy link
Contributor

@lazcamus lazcamus commented Aug 9, 2024

The existing cacert() implementation builds the single bundle of certs in
/etc/ssl/certs/ca-certifates.crt. This isn't read by default, and results in
a verification error:

r00t@9c80da3575a7:~# echo | openssl s_client -connect www.google.com:443 2>&1 | grep Verify
Verify return code: 20 (unable to get local issuer certificate)

The default path for the single cert bundle is /usr/lib/ssl/cert.pem

r00t@9c80da3575a7:~# ln -sf /etc/ssl/certs/ca-certificates.crt /usr/lib/ssl/cert.pem
r00t@9c80da3575a7:~# echo | openssl s_client -connect www.google.com:443 2>&1 | grep Verify
Verify return code: 0 (ok)

So ship that symlink as part of cacert()

openssl looks in `/usr/lib/ssl` for `cert.pem` for bundled certificates
to trust. symlink it to the `ca-certificates.crt` in `/etc/ssl/certs`
@thesayyn
Copy link
Collaborator

thesayyn commented Aug 9, 2024

@loosebazooka is the expert, wdyt?

Copy link
Collaborator

@thesayyn thesayyn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, i'll defer to @loosebazooka for final approval.

@thesayyn
Copy link
Collaborator

ping @loosebazooka

@loosebazooka
Copy link
Member

Oh I assume it's a Debian thing. Lemme do a little reading but this looks fine

@lazcamus
Copy link
Contributor Author

lazcamus commented Aug 21, 2024 via email

Copy link
Member

@loosebazooka loosebazooka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@loosebazooka loosebazooka merged commit 5f855ed into GoogleContainerTools:main Aug 21, 2024
7 checks passed
@loosebazooka
Copy link
Member

@thesayyn I think we have to revert this. It looks to be creating some issues downstream on various distroless containers: GoogleContainerTools/distroless#1679, GoogleContainerTools/distroless#1676

loosebazooka added a commit that referenced this pull request Sep 21, 2024
@lazcamus
Copy link
Contributor Author

lazcamus commented Sep 23, 2024

GoogleContainerTools/distroless#1679

I think just making the parent directory might fix this one?

    mtree.add_parents("/usr/lib/ssl", mode = "0755", time = ctx.attr.time, skip = [1])

GoogleContainerTools/distroless#1676

this one doesn't seem related to the new symlink?

% docker run --rm -it gcr.io/distroless/base-debian12:debug
/ # mv /usr/lib/ssl/cert.pem /usr/lib/ssl/oldcert.pem
/ # wget -S https://sts.nih.gov/.well-known/openid-configuration -O -
Connecting to sts.nih.gov (128.231.243.251:443)
wget: note: TLS certificate validation not implemented
wget: got bad TLS record (len:0) while expecting handshake record
wget: error getting response: Connection reset by peer

There's also SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt set in the environment on that container ... so why would the symlink matter?

It'd be useful to know what old container it worked on to be able to bisect the breakage. My docker repository-fu isn't good enough to find old releases of the distroless base-debian12 debug image, and the image metadata setting timestamps to 1970 makes a simple timestamp sort not a viable strategy.

@loosebazooka
Copy link
Member

loosebazooka commented Sep 23, 2024

I think something like this should be an additional function (exposed via explicit configuration).

I don't mind including this -- but I have to ensure distroless works first and always (as my primary concern) -- where we only need to be debian compliant.

@lazcamus
Copy link
Contributor Author

lazcamus commented Sep 24, 2024 via email

@loosebazooka
Copy link
Member

Yeah those are fair clarifications. The intent is not that this feature was wrong, but that we don't know what's wrong yet and we need to revert while we figure it out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants