Skip to content

Commit 1fa6c71

Browse files
committed
add tinkerbell-insecure-tls param to control InsecureSkipVerify
- this allows using TLS but without verifying certificates/CAs/hostnames etc - fix e2e tests for new tlsInsecure parameter - add `// #nosec G402` so we can actually use InsecureSkipVerify - make gofumpt happy Signed-off-by: Ricardo Pardini <ricardo@pardini.net>
1 parent 376c9ae commit 1fa6c71

File tree

4 files changed

+10
-5
lines changed

4 files changed

+10
-5
lines changed

cmd/tink-worker/cmd/root.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ func NewRootCommand(version string) *cobra.Command {
5757
conn, err := client.NewClientConn(
5858
viper.GetString("tinkerbell-grpc-authority"),
5959
viper.GetBool("tinkerbell-tls"),
60+
viper.GetBool("tinkerbell-insecure-tls"),
6061
)
6162
if err != nil {
6263
return err
@@ -104,6 +105,7 @@ func NewRootCommand(version string) *cobra.Command {
104105
rootCmd.Flags().Int64("max-file-size", defaultMaxFileSize, "Maximum file size in bytes (MAX_FILE_SIZE)")
105106
rootCmd.Flags().Bool("capture-action-logs", true, "Capture action container output as part of worker logs")
106107
rootCmd.Flags().Bool("tinkerbell-tls", true, "Connect to server via TLS or not (TINKERBELL_TLS)")
108+
rootCmd.Flags().Bool("tinkerbell-insecure-tls", false, "When connecting via TLS, enable insecure TLS via InsecureSkipVerify (TINKERBELL_INSECURE_TLS)")
107109
rootCmd.Flags().StringP("docker-registry", "r", "", "Sets the Docker registry (DOCKER_REGISTRY)")
108110
rootCmd.Flags().StringP("registry-username", "u", "", "Sets the registry username (REGISTRY_USERNAME)")
109111
rootCmd.Flags().StringP("registry-password", "p", "", "Sets the registry-password (REGISTRY_PASSWORD)")

cmd/virtual-worker/cmd/root.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ func NewRootCommand(version string) *cobra.Command {
5151
conn, err := client.NewClientConn(
5252
viper.GetString("tinkerbell-grpc-authority"),
5353
viper.GetBool("tinkerbell-tls"),
54+
viper.GetBool("tinkerbell-insecure-tls"),
5455
)
5556
if err != nil {
5657
return err

internal/client/client.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
package client
22

33
import (
4+
"crypto/tls"
5+
46
"github.com/pkg/errors"
57
"go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc"
68
"google.golang.org/grpc"
79
"google.golang.org/grpc/credentials"
810
"google.golang.org/grpc/credentials/insecure"
911
)
1012

11-
func NewClientConn(authority string, tls bool) (*grpc.ClientConn, error) {
13+
func NewClientConn(authority string, tlsEnabled bool, tlsInsecure bool) (*grpc.ClientConn, error) {
1214
var creds grpc.DialOption
13-
if tls {
14-
creds = grpc.WithTransportCredentials(credentials.NewTLS(nil))
15+
if tlsEnabled { // #nosec G402
16+
creds = grpc.WithTransportCredentials(credentials.NewTLS(&tls.Config{InsecureSkipVerify: tlsInsecure}))
1517
} else {
1618
creds = grpc.WithTransportCredentials(insecure.NewCredentials())
1719
}

internal/e2e/e2e_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ var _ = Describe("Tink API", func() {
8585
}, timeout, interval).Should(Equal("STATE_PENDING"))
8686

8787
By("Running a virtual worker")
88-
conn, err := client.NewClientConn(serverAddr, false)
88+
conn, err := client.NewClientConn(serverAddr, false, false)
8989
Expect(err).NotTo(HaveOccurred())
9090
rClient := proto.NewWorkflowServiceClient(conn)
9191

@@ -155,7 +155,7 @@ var _ = Describe("Tink API", func() {
155155
}, timeout, interval).Should(Equal("STATE_PENDING"))
156156

157157
By("Getting Workflow Contexts")
158-
conn, err := client.NewClientConn(serverAddr, false)
158+
conn, err := client.NewClientConn(serverAddr, false, false)
159159
Expect(err).NotTo(HaveOccurred())
160160
rClient := proto.NewWorkflowServiceClient(conn)
161161
workerID := hardware.Spec.Interfaces[0].DHCP.MAC

0 commit comments

Comments
 (0)