MCPcopy
hub / github.com/smallstep/cli / signAction

Function signAction

command/crypto/jws/sign.go:165–353  ·  view source on GitHub ↗
(ctx *cli.Context)

Source from the content-addressed store, hash-verified

163}
164
165func signAction(ctx *cli.Context) error {
166 var err error
167 var payload []byte
168
169 // Read payload if provided
170 args := ctx.Args()
171 switch len(args) {
172 case 0: // read payload from stdin
173 if payload, err = readPayload(""); err != nil {
174 return err
175 }
176 case 1: // read payload from file or stdin (-)
177 if payload, err = readPayload(args[0]); err != nil {
178 return err
179 }
180 default:
181 return errs.TooManyArguments(ctx)
182 }
183
184 isSubtle := ctx.Bool("subtle")
185 alg := ctx.String("alg")
186
187 x5cCertFile, x5cKeyFile := ctx.String("x5c-cert"), ctx.String("x5c-key")
188 x5tCertFile, x5tKeyFile := ctx.String("x5t-cert"), ctx.String("x5t-key")
189 key := ctx.String("key")
190 jwks := ctx.String("jwks")
191 kid := ctx.String("kid")
192 var isX5C bool
193 if x5cCertFile != "" {
194 if x5cKeyFile == "" {
195 return errs.RequiredWithOrFlag(ctx, "x5c-cert", "key", "x5c-key")
196 }
197 if x5tCertFile != "" {
198 return errs.MutuallyExclusiveFlags(ctx, "x5c-cert", "x5t-cert")
199 }
200 if ctx.IsSet("jwk") {
201 return errs.MutuallyExclusiveFlags(ctx, "x5c-cert", "jwk")
202 }
203 if jwks != "" {
204 return errs.MutuallyExclusiveFlags(ctx, "x5c-cert", "jwks")
205 }
206 isX5C = true
207 }
208
209 var isX5T bool
210 if x5tCertFile != "" {
211 if x5tKeyFile == "" {
212 return errs.RequiredWithOrFlag(ctx, "x5t-cert", "key", "x5t-key")
213 }
214 if x5cCertFile != "" {
215 return errs.MutuallyExclusiveFlags(ctx, "x5t-cert", "x5c-cert")
216 }
217 if ctx.IsSet("jwk") {
218 return errs.MutuallyExclusiveFlags(ctx, "x5t-cert", "jwk")
219 }
220 if jwks != "" {
221 return errs.MutuallyExclusiveFlags(ctx, "x5t-cert", "jwks")
222 }

Callers

nothing calls this directly

Calls 5

CompactSerializeMethod · 0.80
readPayloadFunction · 0.70
StringMethod · 0.65
SignMethod · 0.65
PublicMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…