MCPcopy Create free account
hub / github.com/dgraph-io/dgraph / createCerts

Function createCerts

dgraph/cmd/cert/create.go:242–285  ·  view source on GitHub ↗
(opt *options)

Source from the content-addressed store, hash-verified

240}
241
242func createCerts(opt *options) error {
243 if opt == nil {
244 return errors.New("nil options")
245 }
246
247 if opt.dir == "" {
248 return errors.New("Invalid TLS directory")
249 }
250
251 err := os.Mkdir(opt.dir, 0700)
252 if err != nil && !os.IsExist(err) {
253 return err
254 }
255
256 switch {
257 case opt.keySize < keySizeTooSmall:
258 return errors.New("Key size value is too small (x < 512)")
259 case opt.keySize > keySizeTooLarge:
260 return errors.New("Key size value is too large (x > 4096)")
261 case opt.keySize%2 != 0:
262 return errors.New("Key size value must be a factor of 2")
263 }
264
265 switch opt.curve {
266 case "":
267 case "P224", "P256", "P384", "P521":
268 default:
269 return errors.New(`Elliptic curve value must be one of: P224, P256, P384 or P521`)
270 }
271
272 // no path then save it in certsDir.
273 if filepath.Base(opt.caKey) == opt.caKey {
274 opt.caKey = filepath.Join(opt.dir, opt.caKey)
275 }
276 opt.caCert = filepath.Join(opt.dir, defaultCACert)
277
278 if err := createCAPair(opt); err != nil {
279 return err
280 }
281 if err := createNodePair(opt); err != nil {
282 return err
283 }
284 return createClientPair(opt)
285}

Callers 1

runFunction · 0.85

Calls 3

createCAPairFunction · 0.85
createNodePairFunction · 0.85
createClientPairFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…