// TLSCertificate creates a new TLS certificate from the sign response and the
// private key used.
TLSCertificate creates a new TLS certificate from the sign response and the
private key used.
// TLSCertificate creates a new TLS certificate from the sign response and the // private key used .
func TLSCertificate(sign *api.SignResponse, pk crypto.PrivateKey) (*tls.Certificate, error) {
	certPEM, err := getPEM(sign.ServerPEM)
	if err != nil {
		return nil, err
	}
	caPEM, err := getPEM(sign.CaPEM)
	if err != nil {
		return nil, err
	}
	keyPEM, err := getPEM(pk)
	if err != nil {
		return nil, err
	}
	chain := append(certPEM, caPEM...)
	cert, err := tls.X509KeyPair(chain, keyPEM)
	if err != nil {
		return nil, errors.Wrap(err, "error creating tls certificate")
	}
	leaf, err := x509.ParseCertificate(cert.Certificate[0])
	if err != nil {
		return nil, errors.Wrap(err, "error parsing tls certificate")
	}
	cert.Leaf = leaf
	return &cert, nil
}
func TLSCertificate ( sign * api . SignResponse , pk crypto . PrivateKey ) ( * tls . Certificate , error ) { certPEM , err := getPEM ( sign . ServerPEM ) if err != nil { return nil , err } caPEM , err := getPEM ( sign . CaPEM ) if err != nil { return nil , err } keyPEM , err := getPEM ( pk ) if err != nil { return nil , err } chain := append ( certPEM , caPEM ... ) cert , err := tls . X509KeyPair ( chain , keyPEM ) if err != nil { return nil , errors . Wrap ( err , " " ) } leaf , err := x509 . ParseCertificate ( cert . Certificate [ 0 ] ) if err != nil { return nil , errors . Wrap ( err , " " ) } cert . Leaf = leaf return & cert , nil }
TLSCertificate creates a new TLS certificate from the sign response and the
private key used.
TLSCertificate creates a new TLS certificate from the sign response and the private key used .