(ctx *cli.Context)
| 95 | } |
| 96 | |
| 97 | func createAction(ctx *cli.Context) (err error) { |
| 98 | if err := errs.NumberOfArguments(ctx, 2); err != nil { |
| 99 | return err |
| 100 | } |
| 101 | |
| 102 | pubFile := ctx.Args().Get(0) |
| 103 | privFile := ctx.Args().Get(1) |
| 104 | if pubFile == privFile { |
| 105 | return errs.EqualArguments(ctx, "PUB_FILE", "PRIV_FILE") |
| 106 | } |
| 107 | |
| 108 | insecureMode := ctx.Bool("insecure") |
| 109 | noPass := ctx.Bool("no-password") |
| 110 | passwordFile := ctx.String("password-file") |
| 111 | if noPass && passwordFile != "" { |
| 112 | return errs.IncompatibleFlag(ctx, "no-password", "password-file") |
| 113 | } |
| 114 | if noPass && !insecureMode { |
| 115 | return errs.RequiredWithFlag(ctx, "no-password", "insecure") |
| 116 | } |
| 117 | |
| 118 | // Read password if necessary |
| 119 | var password string |
| 120 | if passwordFile != "" { |
| 121 | password, err = utils.ReadStringPasswordFromFile(passwordFile) |
| 122 | if err != nil { |
| 123 | return err |
| 124 | } |
| 125 | } |
| 126 | |
| 127 | var pub, priv interface{} |
| 128 | fromJWK := ctx.String("from-jwk") |
| 129 | if fromJWK != "" { |
| 130 | switch { |
| 131 | case ctx.IsSet("kty"): |
| 132 | return errs.IncompatibleFlagWithFlag(ctx, "from-jwk", "kty") |
| 133 | case ctx.IsSet("curve"): |
| 134 | return errs.IncompatibleFlagWithFlag(ctx, "from-jwk", "curve") |
| 135 | case ctx.IsSet("size"): |
| 136 | return errs.IncompatibleFlagWithFlag(ctx, "from-jwk", "size") |
| 137 | } |
| 138 | |
| 139 | var jwk *jose.JSONWebKey |
| 140 | jwk, err = jose.ReadKey(fromJWK) |
| 141 | if err != nil { |
| 142 | return err |
| 143 | } |
| 144 | |
| 145 | if jwk.IsPublic() { |
| 146 | pub = jwk.Key |
| 147 | } else { |
| 148 | pub = jwk.Public().Key |
| 149 | priv = jwk.Key |
| 150 | } |
| 151 | } else { |
| 152 | var ( |
| 153 | kty, crv string |
| 154 | size int |
nothing calls this directly
no test coverage detected
searching dependent graphs…