Skip to content

Commit 6626a91

Browse files
authored
Document intentional InsecureSkipVerify usage for non-TLS mode (#1514)
1 parent c9d19cc commit 6626a91

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

pkg/netceptor/conn.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -637,9 +637,17 @@ func verifyServerCertificate(rawCerts [][]byte, _ [][]*x509.Certificate) error {
637637
return fmt.Errorf("insecure connection to secure service")
638638
}
639639

640+
// generateClientTLSConfig creates a TLS config for non-TLS mode connections.
641+
// This is only called when no TLS configuration is provided (see DialContext).
642+
// Receptor supports both TLS and non-TLS connections per the documentation.
643+
// When TLS is configured, users provide their own tls.Config via GetClientTLSConfig.
644+
// InsecureSkipVerify is intentionally true here because:
645+
// 1. This path is for non-TLS mode where the server uses auto-generated self-signed certs
646+
// 2. Custom verification is still performed via VerifyPeerCertificate callback
647+
// 3. The callback (verifyServerCertificate) checks for the insecure connection marker.
640648
func generateClientTLSConfig(host string) *tls.Config {
641649
return &tls.Config{
642-
// #nosec G402 -- InsecureSkipVerify is set true in test context only; production usage is config-driven.
650+
//nolint:gosec // G402: InsecureSkipVerify is intentional for non-TLS mode; see function comment above
643651
InsecureSkipVerify: true,
644652
VerifyPeerCertificate: verifyServerCertificate,
645653
NextProtos: []string{"netceptor"},

0 commit comments

Comments
 (0)