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

Support custom paths for cli cert checks #31988

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

olaughter
Copy link

I confirm that this contribution is made under the terms of the license found in the root directory of this repository's source tree and that I have the authority necessary to make this contribution on behalf of its copyright owner.

This aims to resolve: #31978

I'm hoping I took this in the right direction! I was keen to give this a go. I'm very happy to take feedback and/or see maintainers make necessary changes to this, etc.

The tldr behaviour that i've sought to add is that cert checks will now use the cert paths defined in services.xml if any are found, otherwise it looks for the default cert path.

Look forward to hearing your review!

Copy link
Member

@mpolden mpolden left a comment

Choose a reason for hiding this comment

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

Good job! I have some suggestions though.

if pkg.HasCertificate() {
servicesXML, err := readServicesXML(pkg)
if err != nil {
return fmt.Errorf("Error reading services.xml: %w", err)
Copy link
Member

Choose a reason for hiding this comment

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

Nit: Error messages should be lower-case as this may be concatenated with other errors further up.

Copy link
Author

Choose a reason for hiding this comment

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

Ah good spot!

Comment on lines +31 to +35
for _, certPath := range certPaths {
if ap.hasFile(certPath) {
return true
}
}
Copy link
Member

Choose a reason for hiding this comment

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

This should check that all files are present, not just one.

Copy link
Author

Choose a reason for hiding this comment

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

👍

}
return false
}
}

func (ap *ApplicationPackage) HasMatchingCertificate(certificatePEM []byte) (bool, error) {
Copy link
Member

Choose a reason for hiding this comment

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

This needs to consider all certificates now, not just clients.pem. I think ApplicationPackage could have a method that reads the certificate paths from services XML, then both HasCertificate and HasMatchingCertificate can use this method and you won't have to pass around certPaths everywhere.

Copy link
Author

@olaughter olaughter Sep 7, 2024

Choose a reason for hiding this comment

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

Thanks @mpolden, I'll look at refactoring for this. The issue I had originally was that the xml/config.go file imports the vespa package, leading to a circular import if vespa/application.go wants to make use of the file parsing from xml/config.go. I'll revisit and see what I can do to make it work

Copy link
Author

@olaughter olaughter Sep 7, 2024

Choose a reason for hiding this comment

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

Hey, I've been playing around with this and think I could do with some steer on solving it.

I've been trying to get around the circular imports by changing the vespa package. xml/config.go imports System, from vespa, but moving that to its own package ended up with a lot of files changed without solving the issue. I also tried extracting ApplicationPackage, but again couldn't get that to work on its own. There might be a way of solving it this way but I don't feel confident enough to do it as it seems it would take a more dramatic refactoring then I'm comfortable with.

The only other option I could think of was to recreate some of the xml parsing functionality within ApplicationPackage. It wouldn't be very dry, but would enable this. What do you think is the best way forward?

(btw I'm on the vespa slack so let me know if its easier to chat this through there)

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.

vespa prod deploy requires named clients.pem file
2 participants