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

SSL_CERT_FILE in podman machine's systemd environment #16041

Closed
cluening opened this issue Oct 4, 2022 · 6 comments · Fixed by #16457
Closed

SSL_CERT_FILE in podman machine's systemd environment #16041

cluening opened this issue Oct 4, 2022 · 6 comments · Fixed by #16457
Labels
Good First Issue This issue would be a good issue for a first time contributor to undertake. kind/bug Categorizes issue or PR as related to a bug. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. macos MacOS (OSX) related

Comments

@cluening
Copy link

cluening commented Oct 4, 2022

Is this a BUG REPORT or FEATURE REQUEST? (leave only one on its own line)

/kind bug

Description

I work in an environment that uses an interception proxy, meaning I need to set the normal proxy variables as well as the SSL_CERT_FILE variable when using podman machine on my mac. In recent podman releases, the certificate file gets copied into the VM correctly and almost all of the environment variables get set correctly, except one: the SSL_CERT_FILE variable does not get set at the systemd level to point at the copied-in certificate file. As a result, I am unable to pull images when on my corporate network:

laptop:~ cdlueni$ env | grep -i SSL_
SSL_CERT_FILE=/Users/cdlueni/company.crt
laptop:~ cdlueni$ podman machine init
laptop:~ cdlueni$ podman machine start
laptop:~ cdlueni$ podman pull alpine
Resolved "alpine" as an alias (/etc/containers/registries.conf.d/000-shortnames.conf)
Trying to pull docker.io/library/alpine:latest...
Error: initializing source docker://alpine:latest: pinging container registry registry-1.docker.io: Get "https://registry-1.docker.io/v2/": x509: certificate signed by unknown authority

The error on the last line is due to the proxy's certificate not being set for processes being spawned by systemd. By manually editing /etc/systemd/system/envset-fwcfg.service to force the SSL_CERT_FILE variable to be added to the systemd config and then restarting the podman machine I was able to successfully pull images:

The changed line in envset-fwcfg.service:

ExecStart=/usr/bin/bash -c '/usr/bin/test -f ${FWCFGRAW} &&\
        echo "[Manager]\n#Got from QEMU FW_CFG\nDefaultEnvironment=$(/usr/bin/base64 -d ${FWCFGRAW} | sed -e "s+|+ +g") SSL_CERT_FILE=/etc/containers/certs.d/company.crt\n" > ${SYSTEMD_CONF} ||\
        echo "[Manager]\n#Got nothing from QEMU FW_CFG\n#DefaultEnvironment=\n" > ${SYSTEMD_CONF}'

Successful pull afterward:

laptop:~ cdlueni$ podman machine stop
laptop:~ cdlueni$ podman machine start
laptop:~ cdlueni$ podman pull alpine
Resolved "alpine" as an alias (/etc/containers/registries.conf.d/000-shortnames.conf)
Trying to pull docker.io/library/alpine:latest...
Getting image source signatures
Copying blob sha256:9b18e9b68314027565b90ff6189d65942c0f7986da80df008b8431276885218e
Copying config sha256:a6215f271958c760a2975a6765016044115dbae4b90f414eba3a448a6a26b4f6
Writing manifest to image destination
Storing signatures
a6215f271958c760a2975a6765016044115dbae4b90f414eba3a448a6a26b4f6

It looks to me like, if the SSL_CERT_FILE variable is set on the host, then the correct path to the copy in the VM needs to be added to the systemd environment at VM boot time.

Steps to reproduce the issue:

  1. Start a podman machine on a mac with proxy and certificate variables set

  2. Try to pull an image

Describe the results you received:

SSL certificate errors

Describe the results you expected:

Succesful image pull

Additional information you deem important (e.g. issue happens only occasionally):

Output of podman version:

Client:       Podman Engine
Version:      4.2.1
API Version:  4.2.1
Go Version:   go1.19.1
Built:        Wed Dec 31 17:00:00 1969
OS/Arch:      darwin/arm64

Server:       Podman Engine
Version:      4.2.0
API Version:  4.2.0
Go Version:   go1.18.4
Built:        Thu Aug 11 08:43:11 2022
OS/Arch:      linux/arm64

Output of podman info:

(paste your output here)

Package info (e.g. output of rpm -q podman or apt list podman or brew info podman):

port info podman
podman @4.2.1_1 (sysutils)

Description:          Podman is a tool for running Linux containers. You can do
                      this from a MacOS desktop as long as you have access to a
                      linux box either running inside of a VM on the host, or
                      available via the network. You need to install the remote
                      client and then setup ssh connection information.
Homepage:             https://github.com/containers/podman

Build Dependencies:   go, go-md2man
Runtime Dependencies: gvisor-tap-vsock, qemu
Platforms:            darwin, freebsd, linux
License:              Apache-2
Maintainers:          Email: judaew@macports.org, GitHub: judaew
                      Policy: openmaintainer

Have you tested with the latest version of Podman and have you checked the Podman Troubleshooting Guide? (https://github.com/containers/podman/blob/main/troubleshooting.md)

Yes

Additional environment details (AWS, VirtualBox, physical, etc.):

@openshift-ci openshift-ci bot added the kind/bug Categorizes issue or PR as related to a bug. label Oct 4, 2022
@github-actions github-actions bot added the macos MacOS (OSX) related label Oct 4, 2022
@mheon mheon added the Good First Issue This issue would be a good issue for a first time contributor to undertake. label Oct 4, 2022
@github-actions
Copy link

github-actions bot commented Nov 4, 2022

A friendly reminder that this issue had no activity for 30 days.

@bjorndown
Copy link
Contributor

Related PR: #12748

/etc/profile.d/ssl_cert_file.sh is written during ignition which exports SSL_CERT_FILE.

Scripts in /etc/profile.d are usually only sourced in interactive environments which might be why SSL_CERT_FILE is not available to systemd services.

@bjorndown
Copy link
Contributor

Passing SSL_CERT_FILE via -fw_cfg could be an option. This is also how proxy settings are propagated.

https://github.com/containers/podman/blob/main/pkg/machine/qemu/machine.go#L566-L574

@rhatdan
Copy link
Member

rhatdan commented Nov 4, 2022

@ashley-cui @baude WDYT?

@ashley-cui
Copy link
Member

Sounds reasonable to me! @bjorndown Would you be interested in opening a PR?

@bjorndown
Copy link
Contributor

bjorndown commented Nov 5, 2022

@ashley-cui Yes, I will give it a try.

#16413 does look related. Should I include SSL_CERT_DIR as well? So far it is not being propagated, or at least I have not found references in the code. But for that to work we would need to copy the contents of SSL_CERT_DIR, similar to https://github.com/containers/podman/blob/main/pkg/machine/ignition.go#L494

bjorndown pushed a commit to bjorndown/podman that referenced this issue Nov 9, 2022
…nvironment.

Fixes containers#16041.
Maybe fixes containers#16413.

Signed-off-by: Björn Mosler <dev@bjoern.mosler.ch>
bjorndown pushed a commit to bjorndown/podman that referenced this issue Nov 9, 2022
…nvironment.

Fixes containers#16041.
Maybe fixes containers#16413.

Signed-off-by: Björn Mosler <dev@bjoern.mosler.ch>
bjorndown pushed a commit to bjorndown/podman that referenced this issue Nov 11, 2022
…nvironment.

Fixes containers#16041.
Maybe fixes containers#16413.

Signed-off-by: Björn Mosler <dev@bjoern.mosler.ch>
bjorndown pushed a commit to bjorndown/podman that referenced this issue Nov 14, 2022
…nvironment.

Fixes containers#16041.

Signed-off-by: Björn Mosler <dev@bjoern.mosler.ch>
bjorndown pushed a commit to bjorndown/podman that referenced this issue Nov 18, 2022
…nvironment.

Fixes containers#16041.

Signed-off-by: Björn Mosler <dev@bjoern.mosler.ch>
bjorndown pushed a commit to bjorndown/podman that referenced this issue Nov 20, 2022
…nvironment.

Fixes containers#16041.

Signed-off-by: Björn Mosler <dev@bjoern.mosler.ch>
@github-actions github-actions bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Sep 9, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 9, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Good First Issue This issue would be a good issue for a first time contributor to undertake. kind/bug Categorizes issue or PR as related to a bug. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. macos MacOS (OSX) related
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants