MCPcopy Create free account
hub / github.com/cloudflare/cfssl / selfSignMain

Function selfSignMain

cli/selfsign/selfsign.go:40–120  ·  view source on GitHub ↗
(args []string, c cli.Config)

Source from the content-addressed store, hash-verified

38var selfSignFlags = []string{"config"}
39
40func selfSignMain(args []string, c cli.Config) (err error) {
41 if c.Hostname == "" && !c.IsCA {
42 c.Hostname, args, err = cli.PopFirstArgument(args)
43 if err != nil {
44 return
45 }
46 }
47
48 csrFile, args, err := cli.PopFirstArgument(args)
49 if err != nil {
50 return
51 }
52
53 if len(args) > 0 {
54 return errors.New("too many arguments are provided, please check with usage")
55 }
56
57 csrFileBytes, err := cli.ReadStdin(csrFile)
58 if err != nil {
59 return
60 }
61
62 var req = csr.New()
63 err = json.Unmarshal(csrFileBytes, req)
64 if err != nil {
65 return
66 }
67
68 var key, csrPEM []byte
69 g := &csr.Generator{Validator: genkey.Validator}
70 csrPEM, key, err = g.ProcessRequest(req)
71 if err != nil {
72 key = nil
73 return
74 }
75
76 priv, err := helpers.ParsePrivateKeyPEM(key)
77 if err != nil {
78 key = nil
79 return
80 }
81
82 var profile *config.SigningProfile
83
84 // If there is a config, use its signing policy. Otherwise, leave policy == nil
85 // and NewSigner will use DefaultConfig().
86 if c.CFG != nil {
87 if c.Profile != "" && c.CFG.Signing.Profiles != nil {
88 profile = c.CFG.Signing.Profiles[c.Profile]
89 }
90 if profile == nil {
91 profile = c.CFG.Signing.Default
92 }
93 }
94
95 if profile == nil {
96 profile = config.DefaultConfig()
97 profile.Expiry = 2190 * time.Hour

Callers 2

TestSelfSignMainFunction · 0.85
TestBadSelfSignMainFunction · 0.85

Calls 9

ProcessRequestMethod · 0.95
PopFirstArgumentFunction · 0.92
ReadStdinFunction · 0.92
NewFunction · 0.92
ParsePrivateKeyPEMFunction · 0.92
DefaultConfigFunction · 0.92
SignFunction · 0.92
PrintCertFunction · 0.92
NewMethod · 0.80

Tested by 2

TestSelfSignMainFunction · 0.68
TestBadSelfSignMainFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…