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

fix(backend): support disabling ssl-check-cert #1055

Merged
merged 1 commit into from
Oct 27, 2023
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
6 changes: 6 additions & 0 deletions pkg/commands/backend/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ type CreateCommand struct {
maxTLSVersion cmd.OptionalString
minTLSVersion cmd.OptionalString
name cmd.OptionalString
noSSLCheckCert cmd.OptionalBool
overrideHost cmd.OptionalString
port cmd.OptionalInt
requestCondition cmd.OptionalString
Expand Down Expand Up @@ -85,6 +86,7 @@ func NewCreateCommand(parent cmd.Registerer, g *global.Data, m manifest.Data) *C
c.CmdClause.Flag("max-tls-version", "Maximum allowed TLS version on SSL connections to this backend").Action(c.maxTLSVersion.Set).StringVar(&c.maxTLSVersion.Value)
c.CmdClause.Flag("min-tls-version", "Minimum allowed TLS version on SSL connections to this backend").Action(c.minTLSVersion.Set).StringVar(&c.minTLSVersion.Value)
c.CmdClause.Flag("name", "Backend name").Short('n').Action(c.name.Set).StringVar(&c.name.Value)
c.CmdClause.Flag("no-ssl-check-cert", "Skip checking SSL certs").Action(c.noSSLCheckCert.Set).BoolVar(&c.noSSLCheckCert.Value)
c.CmdClause.Flag("override-host", "The hostname to override the Host header").Action(c.overrideHost.Set).StringVar(&c.overrideHost.Value)
c.CmdClause.Flag("port", "Port number of the address").Action(c.port.Set).IntVar(&c.port.Value)
c.CmdClause.Flag("request-condition", "Condition, which if met, will select this backend during a request").Action(c.requestCondition.Set).StringVar(&c.requestCondition.Value)
Expand Down Expand Up @@ -170,6 +172,9 @@ func (c *CreateCommand) Exec(_ io.Reader, out io.Writer) error {
if c.minTLSVersion.WasSet {
input.MinTLSVersion = &c.minTLSVersion.Value
}
if c.noSSLCheckCert.WasSet {
input.SSLCheckCert = fastly.CBool(false)
}
if c.overrideHost.WasSet {
input.OverrideHost = &c.overrideHost.Value
}
Expand All @@ -186,6 +191,7 @@ func (c *CreateCommand) Exec(_ io.Reader, out io.Writer) error {
input.SSLCertHostname = &c.sslCertHostname.Value
}
if c.sslCheckCert.WasSet {
text.Deprecated(out, "The Fastly API defaults `ssl_check_cert` to true. Use `--no-ssl-check-cert` to disable this setting.\n\n")
input.SSLCheckCert = fastly.CBool(c.sslCheckCert.Value)
}
if c.sslCiphers.WasSet {
Expand Down
42 changes: 25 additions & 17 deletions pkg/commands/backend/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ package backend
import (
"io"

"github.com/fastly/go-fastly/v8/fastly"

"github.com/fastly/cli/pkg/cmd"
"github.com/fastly/cli/pkg/errors"
"github.com/fastly/cli/pkg/global"
"github.com/fastly/cli/pkg/manifest"
"github.com/fastly/cli/pkg/text"
"github.com/fastly/go-fastly/v8/fastly"
)

// UpdateCommand calls the Fastly API to update backends.
Expand All @@ -20,31 +21,32 @@ type UpdateCommand struct {
autoClone cmd.OptionalAutoClone

name string
NewName cmd.OptionalString
Comment cmd.OptionalString
Address cmd.OptionalString
Port cmd.OptionalInt
OverrideHost cmd.OptionalString
AutoLoadbalance cmd.OptionalBool
BetweenBytesTimeout cmd.OptionalInt
Comment cmd.OptionalString
ConnectTimeout cmd.OptionalInt
MaxConn cmd.OptionalInt
FirstByteTimeout cmd.OptionalInt
BetweenBytesTimeout cmd.OptionalInt
AutoLoadbalance cmd.OptionalBool
Weight cmd.OptionalInt
RequestCondition cmd.OptionalString
HealthCheck cmd.OptionalString
Hostname cmd.OptionalString
Shield cmd.OptionalString
UseSSL cmd.OptionalBool
SSLCheckCert cmd.OptionalBool
MaxConn cmd.OptionalInt
MaxTLSVersion cmd.OptionalString
MinTLSVersion cmd.OptionalString
NewName cmd.OptionalString
NoSSLCheckCert cmd.OptionalBool
OverrideHost cmd.OptionalString
Port cmd.OptionalInt
RequestCondition cmd.OptionalString
SSLCACert cmd.OptionalString
SSLCertHostname cmd.OptionalString
SSLCheckCert cmd.OptionalBool
SSLCiphers cmd.OptionalString
SSLClientCert cmd.OptionalString
SSLClientKey cmd.OptionalString
SSLCertHostname cmd.OptionalString
SSLSNIHostname cmd.OptionalString
MinTLSVersion cmd.OptionalString
MaxTLSVersion cmd.OptionalString
SSLCiphers cmd.OptionalString
Shield cmd.OptionalString
UseSSL cmd.OptionalBool
Weight cmd.OptionalInt
}

// NewUpdateCommand returns a usable command registered under the parent.
Expand Down Expand Up @@ -82,6 +84,7 @@ func NewUpdateCommand(parent cmd.Registerer, g *global.Data, m manifest.Data) *U
c.CmdClause.Flag("max-tls-version", "Maximum allowed TLS version on SSL connections to this backend").Action(c.MaxTLSVersion.Set).StringVar(&c.MaxTLSVersion.Value)
c.CmdClause.Flag("min-tls-version", "Minimum allowed TLS version on SSL connections to this backend").Action(c.MinTLSVersion.Set).StringVar(&c.MinTLSVersion.Value)
c.CmdClause.Flag("new-name", "New backend name").Action(c.NewName.Set).StringVar(&c.NewName.Value)
c.CmdClause.Flag("no-ssl-check-cert", "Skip checking SSL certs").Action(c.NoSSLCheckCert.Set).BoolVar(&c.NoSSLCheckCert.Value)
c.CmdClause.Flag("override-host", "The hostname to override the Host header").Action(c.OverrideHost.Set).StringVar(&c.OverrideHost.Value)
c.CmdClause.Flag("port", "Port number of the address").Action(c.Port.Set).IntVar(&c.Port.Value)
c.CmdClause.Flag("request-condition", "condition, which if met, will select this backend during a request").Action(c.RequestCondition.Set).StringVar(&c.RequestCondition.Value)
Expand Down Expand Up @@ -195,7 +198,12 @@ func (c *UpdateCommand) Exec(_ io.Reader, out io.Writer) error {
input.UseSSL = fastly.CBool(c.UseSSL.Value)
}

if c.NoSSLCheckCert.WasSet {
input.SSLCheckCert = fastly.CBool(false)
}

if c.SSLCheckCert.WasSet {
text.Deprecated(out, "The Fastly API defaults `ssl_check_cert` to true. Use `--no-ssl-check-cert` to disable this setting.\n\n")
input.SSLCheckCert = fastly.CBool(c.SSLCheckCert.Value)
}

Expand Down
Loading