File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -70,7 +70,8 @@ func (c *Client) Connect(ctx context.Context) error {
7070
7171 tlsConfig , err := c .tlsConfig ()
7272 if err != nil {
73- return err
73+ slog .Error ("TLS configuration failed" , "error" , err )
74+ return errors .New ("TLS configuration error: verify CA certificate configuration. Check server logs for details." )
7475 }
7576
7677 var conn * grpc.ClientConn
Original file line number Diff line number Diff line change @@ -313,6 +313,23 @@ func TestClient_tlsConfig_NonexistentCACertPath(t *testing.T) {
313313 assert .Contains (t , err .Error (), "failed to access CA certificate" )
314314}
315315
316+ func TestClient_Connect_SanitizesTLSConfigError (t * testing.T ) {
317+ client := & Client {
318+ config : & config.CentralConfig {
319+ URL : "central.stackrox.io:8443" ,
320+ AuthType : config .AuthTypeStatic ,
321+ APIToken : "dummy" ,
322+ CACertPath : "/nonexistent/secret/path/ca.crt" ,
323+ },
324+ }
325+
326+ err := client .Connect (context .Background ())
327+ require .Error (t , err )
328+ assert .NotContains (t , err .Error (), "/nonexistent/secret/path/ca.crt" )
329+ assert .Contains (t , err .Error (), "TLS configuration error" )
330+ assert .Contains (t , err .Error (), "Check server logs for details" )
331+ }
332+
316333// generateTestCert creates a certificate PEM with the given options, signed by the given CA.
317334// If ca/caKey are nil, the cert is self-signed.
318335func generateTestCert (
You can’t perform that action at this time.
0 commit comments