isle/go/nebula/certificate.go

30 lines
758 B
Go
Raw Normal View History

package nebula
import "github.com/slackhq/nebula/cert"
// Certificate wraps a NebulaCertificate to provide convenient (and consistent)
// text (un)marshaling methods.
type Certificate struct {
inner cert.NebulaCertificate
}
// Unwrap returns the wrapped NebulaCertificate type.
func (c Certificate) Unwrap() *cert.NebulaCertificate {
return &c.inner
}
// MarshalText implements the encoding.TextMarshaler interface.
func (c Certificate) MarshalText() ([]byte, error) {
return c.inner.MarshalToPEM()
}
// UnmarshalText implements the encoding.TextUnmarshaler interface.
func (c *Certificate) UnmarshalText(b []byte) error {
nebCrt, _, err := cert.UnmarshalNebulaCertificateFromPEM(b)
if err != nil {
return err
}
c.inner = *nebCrt
return nil
}