From 2dabbc5729d98d386ab6909b35ea1c9bb89128cc Mon Sep 17 00:00:00 2001 From: Javier Rodriguez Date: Thu, 9 Apr 2026 11:42:28 +0200 Subject: [PATCH] fix(cli): handle inline PEM CA content in artifact download The artifact download command unconditionally passed the CAS CA config value to WithCAFile(), which fails with "file name too long" when the value contains inline PEM content instead of a file path. Use os.Stat() to distinguish paths from PEM content, matching the existing pattern in root.go and action.go. Signed-off-by: Javier Rodriguez --- app/cli/cmd/artifact.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/app/cli/cmd/artifact.go b/app/cli/cmd/artifact.go index 1d82110a1..abcf3da5d 100644 --- a/app/cli/cmd/artifact.go +++ b/app/cli/cmd/artifact.go @@ -1,5 +1,5 @@ // -// Copyright 2023-2025 The Chainloop Authors. +// Copyright 2023-2026 The Chainloop Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -17,6 +17,7 @@ package cmd import ( "context" + "os" pb "github.com/chainloop-dev/chainloop/app/controlplane/api/controlplane/v1" "github.com/chainloop-dev/chainloop/pkg/grpcconn" @@ -54,8 +55,12 @@ func wrappedArtifactConn(cpConn *grpc.ClientConn, role pb.CASCredentialsServiceG grpcconn.WithInsecure(apiInsecure()), } - if caFilePath := viper.GetString(confOptions.CASCA.viperKey); caFilePath != "" { - opts = append(opts, grpcconn.WithCAFile(caFilePath)) + if caValue := viper.GetString(confOptions.CASCA.viperKey); caValue != "" { + if _, err := os.Stat(caValue); err == nil { + opts = append(opts, grpcconn.WithCAFile(caValue)) + } else { + opts = append(opts, grpcconn.WithCAContent(caValue)) + } } return grpcconn.New(viper.GetString(confOptions.CASAPI.viperKey), resp.Result.Token, opts...)