GRPC mTLS Per VU/Iteration

Hi, I am using K6 to connect to a gRPC API and I have the requirement to specify the TLS credentials per user for mTLS. Specifying them on the connect call would be convenient but I can’t see a way to do that although I am sure I am probably just missing something.

In the code i can see that the TLS config comes from the state but i didn’t think i could set that in VU code?

		if !isPlaintext {
			tlsCfg := state.TLSConfig.Clone()
			tlsCfg.NextProtos = []string{"h2"}

			// TODO(rogchap): Would be good to add support for custom RootCAs (self signed)

			// (rogchap) we create a wrapper for transport credentials so that we can report
			// on any TLS errors.
			creds := transportCreds{
			opts = append(opts, grpc.WithTransportCredentials(creds))

Yes, unfortunately this isn’t currently possible, please open a new issue about it.

hi @ned I didnt understand the answer here, so
¿does k6 support mTLS certificates? or does not?

k6 supports a global TLS client certificate, see Options reference
k6 doesn’t support per-connection/per-VU/per-iteration TLS client certificates yet.

1 Like