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

Function bundlerMain

cli/bundle/bundle.go:29–85  ·  view source on GitHub ↗

bundlerMain is the main CLI of bundler functionality.

(args []string, c cli.Config)

Source from the content-addressed store, hash-verified

27
28// bundlerMain is the main CLI of bundler functionality.
29func bundlerMain(args []string, c cli.Config) (err error) {
30 bundler.IntermediateStash = c.IntDir
31 ubiquity.LoadPlatforms(c.Metadata)
32 flavor := bundler.BundleFlavor(c.Flavor)
33 var b *bundler.Bundler
34 // If it is a force bundle, don't require ca bundle and intermediate bundle
35 // Otherwise, initialize a bundler with CA bundle and intermediate bundle.
36 if flavor == bundler.Force {
37 b = &bundler.Bundler{}
38 } else {
39 b, err = bundler.NewBundler(c.CABundleFile, c.IntBundleFile)
40 if err != nil {
41 return
42 }
43 }
44
45 var bundle *bundler.Bundle
46 if c.CertFile != "" {
47 if c.CertFile == "-" {
48 var certPEM, keyPEM []byte
49 certPEM, err = cli.ReadStdin(c.CertFile)
50 if err != nil {
51 return
52 }
53 if c.KeyFile != "" {
54 keyPEM, err = cli.ReadStdin(c.KeyFile)
55 if err != nil {
56 return
57 }
58 }
59 bundle, err = b.BundleFromPEMorDER(certPEM, keyPEM, flavor, "")
60 if err != nil {
61 return
62 }
63 } else {
64 // Bundle the client cert
65 bundle, err = b.BundleFromFile(c.CertFile, c.KeyFile, flavor, c.Password)
66 if err != nil {
67 return
68 }
69 }
70 } else if c.Domain != "" {
71 bundle, err = b.BundleFromRemote(c.Domain, c.IP, flavor)
72 if err != nil {
73 return
74 }
75 } else {
76 return errors.New("Must specify bundle target through -cert or -domain")
77 }
78
79 marshaled, err := bundle.MarshalJSON()
80 if err != nil {
81 return
82 }
83 fmt.Printf("%s", marshaled)
84 return
85}
86

Callers

nothing calls this directly

Calls 9

BundleFromPEMorDERMethod · 0.95
BundleFromFileMethod · 0.95
BundleFromRemoteMethod · 0.95
MarshalJSONMethod · 0.95
LoadPlatformsFunction · 0.92
BundleFlavorTypeAlias · 0.92
NewBundlerFunction · 0.92
ReadStdinFunction · 0.92
NewMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…