Skip to content

Commit

Permalink
Merge pull request #278 from depot/feat/tls-config-sni-validation
Browse files Browse the repository at this point in the history
feat: add server name to verify the hostname on the returned certificates
  • Loading branch information
goller authored May 2, 2024
2 parents 7dfab95 + 7ec7731 commit 6023b8a
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pkg/cmd/buildctl/dial-stdio.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ func tlsConn(ctx context.Context, builder *machine.Machine) (net.Conn, error) {
return nil, fmt.Errorf("failed to append ca certs")
}

cfg := &tls.Config{RootCAs: certPool}
cfg := &tls.Config{RootCAs: certPool, ServerName: builder.ServerName}
if builder.Cert != "" || builder.Key != "" {
cert, err := tls.X509KeyPair([]byte(builder.Cert), []byte(builder.Key))
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/connection/machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func TLSConn(ctx context.Context, builder *machine.Machine) (net.Conn, error) {
return nil, fmt.Errorf("failed to append ca certs")
}

cfg := &tls.Config{RootCAs: certPool}
cfg := &tls.Config{RootCAs: certPool, ServerName: builder.ServerName}
if builder.Cert != "" || builder.Key != "" {
cert, err := tls.X509KeyPair([]byte(builder.Cert), []byte(builder.Key))
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/machine/machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ func (m *Machine) Client(ctx context.Context) (*client.Client, error) {
}
caCert := file.Name()

opts = append(opts, client.WithCredentials("", caCert, cert, key))
opts = append(opts, client.WithCredentials(m.ServerName, caCert, cert, key))
}

if m.useGzip {
Expand Down

0 comments on commit 6023b8a

Please sign in to comment.