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

certificate propagation throughout the build process #647

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

one-horned-flying
Copy link

During the "Resolving package dependencies..." phase the Dockerfile does not contain the certificates which are put in the certificates folder. This adds those certs so that the rest of the build process can succeed.

Copy link
Contributor

@ipetrov117 ipetrov117 left a comment

Choose a reason for hiding this comment

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

Hey @one-horned-flying and thank you for your contribution! 🚀

Could I ask you to describe the problem that you hit in an Issue and link it to this PR as well, thanks!

Apart from the review comments below, I believe we should not bundle the certificates for both the EIB-built image and the RPM resolution container together. The certificate requirements for these two components may differ, and bundling them could lead to unnecessary certificates being included in either the RPM resolution container or the EIB-built image. This could introduce unexpected issues.

In this PR, I suggest to implement the following image configuration directory structure enhancement:

.
├── ...
├── certificates
│   ├── custom-image-ca.crt
│   └── custom-image-ca.pem
├── ...
└── rpms
    └── certificates
        ├── rpm-resolution-ca.crt
        └── rpm-resolution-ca.pem

Where:

  • certificates - this directory will continue to only be used for certificates related to the custom image that EIB is building.
  • rpms/certificates - new directory that will hold certificates that will only be propagated to the RPM resolution container.

Doing this will ensure that no unnecessary certificates are placed in the corresponding containers/images, which will mitigate any possible unforeseen problems. Let me know what you think. CC: @atanasdinov

@@ -1,6 +1,9 @@
# ----- EIB Builder Image -----
Copy link
Contributor

Choose a reason for hiding this comment

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

There is no need to add the certificates as part of the EIB Dockerfile itself. The EIB Dockerfile is running a fixed set of configurations that are proven to successfully build an EIB container image.

Any configurations for EIB or its underlying RPM resolution process must be done only from EIB's image configuration directory.

Based on this I suggest we remove the certificate inclusion from here.

Copy link
Author

Choose a reason for hiding this comment

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

In my environment, the outgoing traffic is reencrypted at the edge and monitored, that means I have a cert that I need to add to the trust for building of the base EIB image. When using the upstream image it is pretty simple to just add my needed certs though.

Copy link
Author

Choose a reason for hiding this comment

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

basically an accepted MITM :)

@@ -0,0 +1 @@
*
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as the comment above, can we remove this file and directory. EIB configurations should be done only from EIB's image configuration directory.

@@ -14,12 +14,12 @@ import (
)

type mockRPMResolver struct {
resolveFunc func(packages *image.Packages, localRPMConfig *image.LocalRPMConfig, outputDir string) (rpmDir string, pkgList []string, err error)
resolveFunc func(packages *image.Packages, localRPMConfig *image.LocalRPMConfig, certsPath, outputDir string) (rpmDir string, pkgList []string, err error)
Copy link
Contributor

Choose a reason for hiding this comment

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

This change needs to be reflected in the resolveFunc functions of the TestConfigureRPMs_ResolutionFailures and the TestConfigureRPMs_SuccessfulConfig test cases.

return fmt.Errorf("creating certificates dir %s: %w", certsDest, err)
}

if _, err := os.Stat(certsPath); os.IsNotExist(err) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I suggest moving the validation before the actual resolver-image-build/certificates directory creation. No need to create a directory if the root certificates directory is empty.

Also we could probably use the existing fileio.FileExists function here.

@@ -16,6 +16,8 @@ COPY {{ .FromGPGPath }} {{ .ToGPGPath }}
{{ end -}}
{{ end }}

COPY certificates/. /etc/pki/trust/anchors/
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd suggest to avoid hardcoding the path to the certificates directory in the Dockerfile.tpl file. Instead pass the path from the code and have a template here as it is for the other properties. That way if a change needs to happen it could only be done in a single place. Templating for the resolver's Dockerfile.tpl is happening in the writeDockerfile function.

@one-horned-flying one-horned-flying marked this pull request as draft February 6, 2025 17:03
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.

2 participants