grafana/k6 · error
failed to load TLS credentials from file
Error message
failed to load TLS credentials from file: %w
What it means
Wrapped error from dialOptionsFromClientConfig when TLS is not insecure and a cert file is configured: grpc's credentials.NewClientTLSFromFile could not load/parse the file at cfg.TLSConfig.CertFile, so the dial options cannot be built.
Solutions
- Ensure the configured cert file path exists and is readable by k6
- Verify the file is a valid PEM-encoded certificate
- Remove the cert setting to use the system/default TLS roots if appropriate
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at internal/cloudapi/insights/client.go:228 when the library encounters an invalid state.
Common situations: See trigger scenarios.
Understand the failure class
- SSL/TLS and certificate errors — how TLS handshakes and certificate validation fail.
AI-assisted analysis of grafana/k6@01ffac6f24 (2026-08-18).
Data as JSON: /api/errors/460cb524a360d8a3.
Report an issue: GitHub.
Appendix: source
Thrown at internal/cloudapi/insights/client.go:228
if cfg.ConnectConfig.Block {
opts = append(opts, grpc.WithBlock()) //nolint:staticcheck
}
if cfg.ConnectConfig.FailOnNonTempDialError {
opts = append(opts, grpc.FailOnNonTempDialError(true)) //nolint:staticcheck
}
if cfg.ConnectConfig.Dialer != nil {
opts = append(opts, grpc.WithContextDialer(cfg.ConnectConfig.Dialer))
}
if cfg.TLSConfig.Insecure { //nolint: nestif
opts = append(opts, grpc.WithTransportCredentials(insecure.NewCredentials()))
} else {
if cfg.TLSConfig.CertFile != "" {
creds, err := credentials.NewClientTLSFromFile(cfg.TLSConfig.CertFile, "")
if err != nil {
return nil, fmt.Errorf("failed to load TLS credentials from file: %w", err)
}
opts = append(opts, grpc.WithTransportCredentials(creds))
} else {
opts = append(opts, grpc.WithTransportCredentials(credentials.NewTLS(&tls.Config{MinVersion: tls.VersionTLS13})))
}
}
if cfg.AuthConfig.Enabled {
opts = append(opts, grpc.WithPerRPCCredentials(newPerRPCCredentials(cfg.AuthConfig)))
}
rI, err := retryInterceptor(cfg.RetryConfig)
if err != nil {
return nil, fmt.Errorf("failed to create retry interceptors: %w", err)
}
opts = append(opts, grpc.WithChainUnaryInterceptor([]grpc.UnaryClientInterceptor{rI}...))
View on GitHub (pinned to 01ffac6f24)