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

feat: add ssl support to sync service (#1479) #1501

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

alexandraoberaigner
Copy link

This PR

Adds SSL support to the flagd sync service

Related Issues

Fixes #1479

How to test

run make test-flagd

@alexandraoberaigner alexandraoberaigner requested a review from a team as a code owner January 7, 2025 16:35
@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Jan 7, 2025
@alexandraoberaigner alexandraoberaigner force-pushed the fix/1479-bug-not-supporting-ssl branch from ced5619 to 80ff0da Compare January 7, 2025 16:36
Copy link

netlify bot commented Jan 7, 2025

Deploy Preview for polite-licorice-3db33c canceled.

Name Link
🔨 Latest commit ced5619
🔍 Latest deploy log https://app.netlify.com/sites/polite-licorice-3db33c/deploys/677d57e999f813000857e2d5

Copy link

netlify bot commented Jan 7, 2025

Deploy Preview for polite-licorice-3db33c canceled.

Name Link
🔨 Latest commit feebc44
🔍 Latest deploy log https://app.netlify.com/sites/polite-licorice-3db33c/deploys/677f9422c9900a0008915123

Signed-off-by: Alexandra Oberaigner <[email protected]>
@alexandraoberaigner
Copy link
Author

alexandraoberaigner commented Jan 7, 2025

[QUESTION] can someone help me with a maintainable solution of the certificate generation. Is it okay to run a script at the beginning of the test to generate the files (see Makefile & script)? I figured that just committing these files is not really maintainable since they expire after the on creation specified number of days. What would be good practice?

@toddbaert
Copy link
Member

[QUESTION] can someone help me with a maintainable solution of the certificate generation. Is it okay to run a script at the beginning of the test to generate the files (see Makefile & script)? I figured that just committing these files is not really maintainable since they expire after the on creation specified number of days. What would be good practice?

Is it okay to run a script at the beginning of the test to generate the files?

Yep, that's fine with me, BUT:

I can specify days 9999 in openssl which generates a cert until 2055. I'm OK with committing that, as long as it's in a folder clearly labelled "test" or something. We have other repos in the org that do the same thing, and I've seen it in many projects that do testing with SSL.

@aepfli
Copy link
Member

aepfli commented Jan 7, 2025

[QUESTION] can someone help me with a maintainable solution of the certificate generation. Is it okay to run a script at the beginning of the test to generate the files (see Makefile & script)? I figured that just committing these files is not really maintainable since they expire after the on creation specified number of days. What would be good practice?

Is it okay to run a script at the beginning of the test to generate the files?

Yep, that's fine with me, BUT:

I can specify days 9999 in openssl which generates a cert until 2055. I'm OK with committing that, as long as it's in a folder clearly labelled "test" or something. We have other repos in the org that do the same thing, and I've seen it in many projects that do testing with SSL.

should we maybe use the one from the flagd-testbed also within here?

@toddbaert
Copy link
Member

[QUESTION] can someone help me with a maintainable solution of the certificate generation. Is it okay to run a script at the beginning of the test to generate the files (see Makefile & script)? I figured that just committing these files is not really maintainable since they expire after the on creation specified number of days. What would be good practice?

Is it okay to run a script at the beginning of the test to generate the files?

Yep, that's fine with me, BUT:
I can specify days 9999 in openssl which generates a cert until 2055. I'm OK with committing that, as long as it's in a folder clearly labelled "test" or something. We have other repos in the org that do the same thing, and I've seen it in many projects that do testing with SSL.

should we maybe use the one from the flagd-testbed also within here?

Yep we could do that. What's the expiry on that one?

@beeme1mr beeme1mr changed the title fix: add ssl support to sync service (#1479) feat: add ssl support to sync service (#1479) Jan 7, 2025
@alexandraoberaigner
Copy link
Author

[QUESTION] can someone help me with a maintainable solution of the certificate generation. Is it okay to run a script at the beginning of the test to generate the files (see Makefile & script)? I figured that just committing these files is not really maintainable since they expire after the on creation specified number of days. What would be good practice?

Is it okay to run a script at the beginning of the test to generate the files?

Yep, that's fine with me, BUT:
I can specify days 9999 in openssl which generates a cert until 2055. I'm OK with committing that, as long as it's in a folder clearly labelled "test" or something. We have other repos in the org that do the same thing, and I've seen it in many projects that do testing with SSL.

should we maybe use the one from the flagd-testbed also within here?

I went the easy route & added a new certificate to the PR that expires in 9999 days as suggested by @toddbaert, let me know if there speaks something against it

return
}

serviceClient := syncv1grpc.NewFlagSyncServiceClient(con)
Copy link
Author

Choose a reason for hiding this comment

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

[INFO] from this line on the test is the same as before

Signed-off-by: Alexandra Oberaigner <[email protected]>
@alexandraoberaigner alexandraoberaigner force-pushed the fix/1479-bug-not-supporting-ssl branch from ef58650 to d97fc8d Compare January 8, 2025 12:26
Signed-off-by: Alexandra Oberaigner <[email protected]>
flagd/pkg/service/flag-sync/sync_service.go Outdated Show resolved Hide resolved
flagd/pkg/service/flag-sync/util_test.go Outdated Show resolved Hide resolved
flagd/pkg/service/flag-sync/test-cert/server-ext.cnf Outdated Show resolved Hide resolved
flagd/pkg/service/flag-sync/util_test.go Outdated Show resolved Hide resolved
func NewSyncService(cfg SvcConfigurations) (*Service, error) {
l := cfg.Logger
mux, err := NewMux(cfg.Store, cfg.Sources)
if err != nil {
return nil, fmt.Errorf("error initializing multiplexer: %w", err)
}

server := grpc.NewServer()
var server *grpc.Server
tlsCredentials, err := loadTLSCredentials(cfg.CertPath, cfg.KeyPath)
Copy link
Member

Choose a reason for hiding this comment

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

As tls.loadX509...(...) could imply side effects with loading, we should check if CertPath and KeyPath are empty upfront, rather relying on the method itself. Specifically as implementation behind this method can change, and we should only invoke it, if the parameters are set.

Copy link
Member

@aepfli aepfli left a comment

Choose a reason for hiding this comment

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

Thank you. It looks really good, and I love the parameterized test. There is just one thing that we should address, just to be safe.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size:L This PR changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] [sync-service] not supporting SSL
4 participants