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

*: not https warning to show only on http #3124

Merged
merged 1 commit into from
Jun 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ const (
defaultConfigFilename = "charon"

// The environment variable prefix of all environment variables bound to our command line flags.
envPrefix = "charon"
envPrefix = "charon"
httpScheme = "http"
httpsScheme = "https"
)

// New returns a new root cobra command that handles our command line tool.
Expand Down
4 changes: 2 additions & 2 deletions cmd/createcluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ func validateCreateConfig(ctx context.Context, conf clusterConfig) error {
return errors.Wrap(err, "failed to parse keymanager addr", z.Str("addr", addr))
}

if keymanagerURL.Scheme != "https" {
if keymanagerURL.Scheme == httpScheme {
log.Warn(ctx, "Keymanager URL does not use https protocol", nil, z.Str("addr", addr))
}
}
Expand Down Expand Up @@ -1001,7 +1001,7 @@ func loadDefinition(ctx context.Context, defFile string) (cluster.Definition, er
func validURI(str string) bool {
u, err := url.ParseRequestURI(str)

return err == nil && (u.Scheme == "http" || u.Scheme == "https") && u.Host != ""
return err == nil && (u.Scheme == httpScheme || u.Scheme == httpsScheme) && u.Host != ""
}

// safeThreshold logs a warning when a non-standard threshold is provided.
Expand Down
2 changes: 1 addition & 1 deletion cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func bindP2PFlags(cmd *cobra.Command, config *p2p.Config) {
return errors.Wrap(err, "parse relay address", z.Str("address", relay))
}

if u.Scheme == "http" {
if u.Scheme == httpScheme {
log.Warn(cmd.Context(), "Insecure relay address provided, not HTTPS", nil, z.Str("address", relay))
}
}
Expand Down
2 changes: 1 addition & 1 deletion dkg/dkg.go
Original file line number Diff line number Diff line change
Expand Up @@ -1089,7 +1089,7 @@ func validateKeymanagerFlags(ctx context.Context, addr, authToken string) error
return errors.Wrap(err, "failed to parse keymanager addr", z.Str("addr", addr))
}

if keymanagerURL.Scheme != "https" {
if keymanagerURL.Scheme == "http" {
Copy link
Contributor

@pinebit pinebit Jun 6, 2024

Choose a reason for hiding this comment

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

can Scheme be empty string? and what protocol will be running if it's empty?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, that is the case if you don't specify key manager.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If it's empty it would mean there is no external key manager, so it won't use it at all.

log.Warn(ctx, "Keymanager URL does not use https protocol", nil, z.Str("addr", addr))
}

Expand Down
Loading