Skip to content

Commit 28dc67a

Browse files
macdeweeclaude
andcommitted
fix: update TestConnectionTLS for native Go FIPS
Add verification_mode:strict so Go's native TLS stack performs chain verification (InsecureSkipVerify=false) and the FIPS key-size check triggers. Update the expected error string to match native Go's message. Simplify the test comment to remove implementation details. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 2052591 commit 28dc67a

1 file changed

Lines changed: 5 additions & 10 deletions

File tree

libbeat/esleg/eslegclient/connection_test.go

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -240,22 +240,17 @@ func BenchmarkExecHTTPRequest(b *testing.B) {
240240
}
241241
}
242242

243-
// TestConnectionTLS tries to connect to a test HTTPS server (pretending
244-
// to be an Elasticsearch cluster), that deliberately presents TLS options
245-
// that are not FIPS-compliant.
246-
// - If the test is running with a FIPS-capable build, the client, being FIPS-
247-
// capable, should fail the TLS handshake. Concretely, the conn.Connect() method
248-
// should return an error.
249-
// - If the test is not running with a FIPS-capable build, the client should
250-
// complete the TLS handshake successfully. Concretely, the conn.Connect() method
251-
// should not return an error.
243+
// TestConnectionTLS connects to a test HTTPS server that presents a 1024-bit
244+
// RSA certificate, which is below the FIPS 140-3 minimum of 2048 bits.
245+
// In a FIPS build the handshake must fail; in a non-FIPS build it must succeed.
252246
func TestConnectionTLS(t *testing.T) {
253247
server := startTLSServer(t)
254248
defer server.Close()
255249

256250
transportSettings := `
257251
ssl:
258252
enabled: true
253+
verification_mode: strict
259254
`
260255

261256
var transport httpcommon.HTTPTransportSettings
@@ -276,7 +271,7 @@ ssl:
276271
err = conn.Connect(ctx)
277272

278273
if version.FIPSDistribution {
279-
require.ErrorContains(t, err, "tls: internal error")
274+
require.ErrorContains(t, err, "tls: no FIPS compatible certificate chains found")
280275
} else {
281276
require.NoError(t, err)
282277
}

0 commit comments

Comments
 (0)