2017-01-20 19:32:10 +00:00
|
|
|
package service
|
|
|
|
|
|
|
|
import (
|
2017-03-15 15:55:30 +00:00
|
|
|
"context"
|
|
|
|
|
2017-01-20 19:32:10 +00:00
|
|
|
"github.com/go-kit/kit/endpoint"
|
2017-06-22 19:50:45 +00:00
|
|
|
"github.com/kolide/fleet/server/kolide"
|
2017-01-20 19:32:10 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type certificateResponse struct {
|
|
|
|
CertificateChain []byte `json:"certificate_chain"`
|
|
|
|
Err error `json:"error,omitempty"`
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r certificateResponse) error() error { return r.Err }
|
|
|
|
|
|
|
|
func makeCertificateEndpoint(svc kolide.Service) endpoint.Endpoint {
|
|
|
|
return func(ctx context.Context, request interface{}) (interface{}, error) {
|
|
|
|
chain, err := svc.CertificateChain(ctx)
|
|
|
|
if err != nil {
|
|
|
|
return certificateResponse{Err: err}, nil
|
|
|
|
}
|
|
|
|
return certificateResponse{CertificateChain: chain}, nil
|
|
|
|
}
|
|
|
|
}
|