func TLSCredentials(trust *x509.Certificate, client *tls.Certificate) ([]byte, error) {
	var out []byte
	out = append(out, trust.Raw...)
	if client != nil {
		out = append(out, client.Certificate[0]...)
		switch privateKey := client.PrivateKey.(type) {
		case *rsa.PrivateKey:
			out = append(out, x509.MarshalPKCS1PrivateKey(privateKey)...)
		case *ecdsa.PrivateKey:
			privateKeyBytes, err := x509.MarshalECPrivateKey(privateKey)
			if err != nil {
				return nil, err
			}
			out = append(out, privateKeyBytes...)
		default:
			return nil, errUnsupportedPrivateKey.WithAttributes("type", fmt.Sprintf("%T", client.PrivateKey))
		}
	}
	return out, nil
}
TLSCredentials appends the TLS trust certificate and client credentials.
Only the leaf client certificate is included.
package cups
import (
	"bytes"
	"context"
	"crypto/ecdsa"
	"crypto/rsa"
	"crypto/tls"
	"crypto/x509"
	"encoding/binary"
	"fmt"
	"math"
	"strings"
	"go.thethings.network/lorawan-stack/v3/pkg/basicstation"
	"go.thethings.network/lorawan-stack/v3/pkg/errors"
)
var emptyClientCert = []byte{0x00, 0x00, 0x00, 0x00}
type UpdateInfoRequest struct {
	Router             basicstation.EUI `json:"router"`
	CUPSURI            string           `json:"cupsUri"`
	LNSURI             string           `json:"tcUri"`
	CUPSCredentialsCRC uint32           `json:"cupsCredCrc"`
	LNSCredentialsCRC  uint32           `json:"tcCredCrc"`
	Station            string           `json:"station"`
	Model              string           `json:"model"`
	Package            string           `json:"package"`
	KeyCRCs            []uint32         `json:"keys"`
}
var errMissingRouter = errors.DefineInvalidArgument("missing_router", "missing router")
func (req *UpdateInfoRequest) ValidateContext(ctx context.Context) error {
	if req.Router.IsZero() {
		return errMissingRouter.New()
	}
	return nil
}
type UpdateInfoResponse struct {
	CUPSURI         string
	LNSURI          string
	CUPSCredentials []byte
	LNSCredentials  []byte
	SignatureKeyCRC uint32
	Signature       []byte
	UpdateData      []byte
}