MCPcopy Index your code
hub / github.com/smallstep/cli / readExistingUUID

Function readExistingUUID

command/ssh/certificate.go:583–607  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

581}
582
583func readExistingUUID() (uuid.UUID, error) {
584 id, err := identity.LoadDefaultIdentity()
585 if err != nil {
586 return uuid.Nil, errs.Wrap(err, "error loading default identity")
587 }
588 if err := id.Validate(); err != nil {
589 return uuid.Nil, errs.Wrap(err, "error validating identity file")
590 }
591 certs, err := pemutil.ReadCertificateBundle(id.Certificate)
592 if err != nil {
593 return uuid.Nil, errs.Wrap(err, "error parsing default identity")
594 }
595 leaf := certs[0]
596 if len(leaf.URIs) < 1 {
597 return uuid.Nil, errors.New("incompatible certificate: missing host uuid")
598 }
599 uri := leaf.URIs[0]
600 // TODO: add a smallstep namespace at some point
601 // so we can actually find our host id
602 u, err := uuid.Parse(uri.String())
603 if err != nil {
604 return uuid.Nil, errs.Wrap(err, "error parsing host-id")
605 }
606 return u, nil
607}

Callers 1

certificateActionFunction · 0.85

Calls 2

ValidateMethod · 0.80
StringMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…