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

Function renewCertificateAction

command/ca/renew.go:233–352  ·  view source on GitHub ↗
(ctx *cli.Context)

Source from the content-addressed store, hash-verified

231}
232
233func renewCertificateAction(ctx *cli.Context) error {
234 err := errs.NumberOfArguments(ctx, 2)
235 if err != nil {
236 return err
237 }
238
239 args := ctx.Args()
240 certFile := args.Get(0)
241 keyFile := args.Get(1)
242 passFile := ctx.String("password-file")
243 isDaemon := ctx.Bool("daemon")
244 execCmd := ctx.String("exec")
245 kmsURI := ctx.String("kms")
246
247 outFile := ctx.String("out")
248 if outFile == "" {
249 outFile = certFile
250 }
251
252 rootFile := ctx.String("root")
253 if rootFile == "" {
254 rootFile = pki.GetRootCAPath()
255 }
256
257 caURL, err := flags.ParseCaURL(ctx)
258 if err != nil {
259 return err
260 }
261
262 var expiresIn, renewPeriod time.Duration
263 if s := ctx.String("expires-in"); s != "" {
264 if expiresIn, err = time.ParseDuration(s); err != nil {
265 return errs.InvalidFlagValue(ctx, "expires-in", s, "")
266 }
267 }
268 if s := ctx.String("renew-period"); s != "" {
269 if renewPeriod, err = time.ParseDuration(s); err != nil {
270 return errs.InvalidFlagValue(ctx, "renew-period", s, "")
271 }
272 }
273 if expiresIn > 0 && renewPeriod > 0 {
274 return errs.IncompatibleFlagWithFlag(ctx, "expires-in", "renew-period")
275 }
276 if renewPeriod > 0 && !isDaemon {
277 return errs.RequiredWithFlag(ctx, "renew-period", "daemon")
278 }
279
280 if ctx.IsSet("pid") && ctx.IsSet("pid-file") {
281 return errs.MutuallyExclusiveFlags(ctx, "pid", "pid-file")
282 }
283 pid := ctx.Int("pid")
284 if ctx.IsSet("pid") && pid <= 0 {
285 return errs.InvalidFlagValue(ctx, "pid", strconv.Itoa(pid), "")
286 }
287
288 pidFile := ctx.String("pid-file")
289 if pidFile != "" {
290 pidB, err := os.ReadFile(pidFile)

Callers

nothing calls this directly

Calls 9

ParseCaURLFunction · 0.92
tlsLoadX509KeyPairFunction · 0.85
newRenewerFunction · 0.85
getAfterRenewFuncFunction · 0.85
nextRenewDurationFunction · 0.85
SetMethod · 0.80
DaemonMethod · 0.80
StringMethod · 0.65
RenewMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…