NewClient returns a client of an online or offline CA. Requires the flags `offline`, `ca-config`, `ca-url`, and `root`.
(ctx *cli.Context, opts ...ca.ClientOption)
| 50 | // NewClient returns a client of an online or offline CA. Requires the flags |
| 51 | // `offline`, `ca-config`, `ca-url`, and `root`. |
| 52 | func NewClient(ctx *cli.Context, opts ...ca.ClientOption) (CaClient, error) { |
| 53 | if ctx.Bool("offline") { |
| 54 | caConfig := ctx.String("ca-config") |
| 55 | if caConfig == "" { |
| 56 | return nil, errs.InvalidFlagValue(ctx, "ca-config", "", "") |
| 57 | } |
| 58 | return NewOfflineCA(ctx, caConfig) |
| 59 | } |
| 60 | |
| 61 | caURL, err := flags.ParseCaURL(ctx) |
| 62 | if err != nil { |
| 63 | return nil, err |
| 64 | } |
| 65 | root := ctx.String("root") |
| 66 | if root == "" { |
| 67 | root = pki.GetRootCAPath() |
| 68 | if _, err := os.Stat(root); err != nil { |
| 69 | return nil, errs.RequiredFlag(ctx, "root") |
| 70 | } |
| 71 | } |
| 72 | opts = append([]ca.ClientOption{ca.WithRootFile(root)}, opts...) |
| 73 | return ca.NewClient(caURL, opts...) |
| 74 | } |
| 75 | |
| 76 | // NewUnauthenticatedAdminClient returns a unauthenticated client for the mgmt API of the online CA. |
| 77 | func NewUnauthenticatedAdminClient(ctx *cli.Context, opts ...ca.ClientOption) (*ca.AdminClient, error) { |
no test coverage detected
searching dependent graphs…