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

shared: Add helper for obtaining a CertInfo struct #12767

Merged
merged 2 commits into from
Jan 24, 2024

Conversation

masnax
Copy link
Contributor

@masnax masnax commented Jan 23, 2024

CertInfo is used across several LXD-adjacent projects to store certs, but it really only allows populating from a filesystem or from a slice of bytes which results in a lot of back-and-forth conversions:

func KeyPairAndCA(dir, prefix string, kind CertKind, addHosts bool) (*CertInfo, error) {

This introduces a function that instantiates a new CertInfo with the given keypair/ca/crl parameters.

CertInfo is used across several LXD-adjacent projects to store certs,
but it really only allows populating from a filesystem or from a set of
bytes which results in a lot of back-and-forth conversions.

This introduces a function that instantiates a new CertInfo with the
given keypair/ca/crl parameters.

Signed-off-by: Max Asnaashari <[email protected]>
@masnax masnax requested a review from tomponline as a code owner January 23, 2024 17:24
Copy link
Member

@tomponline tomponline left a comment

Choose a reason for hiding this comment

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

Can we use this function in lxd somewhere so we can see it's in use and don't remove it?

@masnax
Copy link
Contributor Author

masnax commented Jan 23, 2024

Can we use this function in lxd somewhere so we can see it's in use and don't remove it?

I've added it to the NetworkCert function. It uses a mutex but returns a pointer to the actual struct so returning a copy of the cert makes more sense.

@tomponline
Copy link
Member

returning a copy of the cert makes more sense.

Yeah that avoids accidental modification.

@tomponline tomponline merged commit 7aa6027 into canonical:main Jan 24, 2024
25 checks passed
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