Documentation ¶
Overview ¶
Package enrollment facilitates the binding of an Area Controller to a Building Controller. The Building Controller connects to the Area Controller, which implements the EnrollmentApi, and gives it metadata about the Smart Core network and a certificate.
This package only implements the communication between the Building Controller and the Area Controller. It does not interact with the database or user interfaces.
Index ¶
- Variables
- func DeleteEnrollment(dir string) error
- func SaveEnrollment(dir string, enrollment Enrollment) (err error)
- type Enrollment
- type Server
- func (es *Server) AutoRenew(ctx context.Context) error
- func (es *Server) Certs() (*tls.Certificate, []*x509.Certificate, error)
- func (es *Server) CreateEnrollment(ctx context.Context, request *gen.CreateEnrollmentRequest) (*gen.Enrollment, error)
- func (es *Server) DeleteEnrollment(ctx context.Context, request *gen.DeleteEnrollmentRequest) (*gen.Enrollment, error)
- func (es *Server) Enrollment() (enrollment Enrollment, ok bool)
- func (es *Server) Enrollments(ctx context.Context) <-chan Enrollment
- func (es *Server) GetEnrollment(_ context.Context, _ *gen.GetEnrollmentRequest) (*gen.Enrollment, error)
- func (es *Server) ManagerAddress(ctx context.Context) <-chan string
- func (es *Server) RequestRenew(ctx context.Context) error
- func (es *Server) TestEnrollment(ctx context.Context, _ *gen.TestEnrollmentRequest) (*gen.TestEnrollmentResponse, error)
- func (es *Server) UpdateEnrollment(ctx context.Context, request *gen.UpdateEnrollmentRequest) (*gen.Enrollment, error)
- func (es *Server) Wait(ctx context.Context) (enrollment Enrollment, done bool)
Constants ¶
This section is empty.
Variables ¶
var ErrNotEnrolled = errors.New("node is not enrolled")
Functions ¶
func DeleteEnrollment ¶
func SaveEnrollment ¶
func SaveEnrollment(dir string, enrollment Enrollment) (err error)
Types ¶
type Enrollment ¶
type Enrollment struct { RootDeviceName string `json:"root_device_name"` ManagerName string `json:"manager_name"` ManagerAddress string `json:"manager_address"` LocalAddress string `json:"local_address"` RootCA *x509.Certificate `json:"-"` Cert tls.Certificate `json:"-"` }
func LoadEnrollment ¶
func LoadEnrollment(dir string, keyPEM []byte) (Enrollment, error)
LoadEnrollment will load a previously saved Enrollment from a directory on disk. The directory should have the following structure:
<root> - enrollment.json - JSON-encoded Enrollment structure - root-ca.crt - Root CA for the enrollment, PEM-encoded X.509 certificate - cert.crt - Certificate chain for keyPEM, with the Root CA at the top of the chain
This node's private key must be passed in, in PEM-wrapped PKCS#1 or PKCS#8 format.
func (Enrollment) Equal ¶
func (e Enrollment) Equal(other Enrollment) bool
func (Enrollment) IsZero ¶
func (e Enrollment) IsZero() bool
type Server ¶
type Server struct { gen.UnimplementedEnrollmentApiServer // contains filtered or unexported fields }
func LoadOrCreateServer ¶
LoadOrCreateServer will try to load an enrollment from disk. If successful, a server in the enrolled state is returned. Otherwise, a server in the unenrolled state is returned and new enrollments will be saved in the provided directory.
func NewServer ¶
NewServer creates an enrollment server, without attempting to load an existing enrollment. The new server will be in an un-enrolled state. New enrollments will be saved in the provided directory.
func (*Server) Certs ¶
func (es *Server) Certs() (*tls.Certificate, []*x509.Certificate, error)
Certs implements pki.Source and provides a certificate source that provides the latest known enrollment certificate. If the certificate source is used while this Server has no enrollment, an error will be returned. This is therefore not suitable for use in enrollment mode - use a self-signed certificate source (with the enrollment private key) instead.
func (*Server) CreateEnrollment ¶
func (es *Server) CreateEnrollment(ctx context.Context, request *gen.CreateEnrollmentRequest) (*gen.Enrollment, error)
func (*Server) DeleteEnrollment ¶
func (es *Server) DeleteEnrollment(ctx context.Context, request *gen.DeleteEnrollmentRequest) (*gen.Enrollment, error)
func (*Server) Enrollment ¶
func (es *Server) Enrollment() (enrollment Enrollment, ok bool)
func (*Server) Enrollments ¶
func (es *Server) Enrollments(ctx context.Context) <-chan Enrollment
Enrollments returns a chan that emits whenever the enrollment status or properties for this server change.
func (*Server) GetEnrollment ¶
func (es *Server) GetEnrollment(_ context.Context, _ *gen.GetEnrollmentRequest) (*gen.Enrollment, error)
func (*Server) ManagerAddress ¶
ManagerAddress returns a chan that emits the manager address whenever it changes. Cancel the given context to stop listening for changes.
func (*Server) RequestRenew ¶
RequestRenew asks the hub to renew our certificate. Errors if this node is not enrolled with a hub.
func (*Server) TestEnrollment ¶
func (es *Server) TestEnrollment(ctx context.Context, _ *gen.TestEnrollmentRequest) (*gen.TestEnrollmentResponse, error)
func (*Server) UpdateEnrollment ¶
func (es *Server) UpdateEnrollment(ctx context.Context, request *gen.UpdateEnrollmentRequest) (*gen.Enrollment, error)