Skip to content
Merged
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
39 changes: 0 additions & 39 deletions internal/integration_tests/test_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"bufio"
"bytes"
"context"
"crypto/tls"
"fmt"
"io"
"net"
Expand Down Expand Up @@ -206,41 +205,3 @@ func HandleTCPConnection(t *testing.T, conn io.ReadWriteCloser) (string, error)

return message, nil
}

// HandleTLSConnection handles a TLS server connection
func HandleTLSConnection(t *testing.T, conn net.Conn, cert *tls.Certificate) (string, error) {
t.Helper()
// Create TLS configuration for server
config := &tls.Config{
Certificates: []tls.Certificate{*cert},
}

// Create a TLS server connection
tlsConn := tls.Server(conn, config)
defer tlsConn.Close()

// Perform TLS handshake
if err := tlsConn.Handshake(); err != nil {
return "", fmt.Errorf("TLS handshake failed: %w", err)
}

// Read data from the TLS connection
buffer := make([]byte, 1024)
n, err := tlsConn.Read(buffer)
if err != nil && err != io.EOF {
return "", fmt.Errorf("error reading from TLS connection: %w", err)
}

message := ""
if n > 0 {
message = string(buffer[:n])

// Send a response back to the client over TLS
response := "TLS message received"
if _, err := tlsConn.Write([]byte(response)); err != nil {
return message, fmt.Errorf("failed to write TLS response: %w", err)
}
}

return message, nil
}
Loading