Forráskód Böngészése

Merge pull request #2563 from omercnet/fix/nebula

Update `github.com/slackhq/nebula` to `v1.10.3`
Herman Slatman 9 hónapja
szülő
commit
20608299c2
4 módosított fájl, 249 hozzáadás és 285 törlés
  1. 50 46
      authority/provisioner/nebula.go
  2. 168 211
      authority/provisioner/nebula_test.go
  3. 11 10
      go.mod
  4. 20 18
      go.sum

+ 50 - 46
authority/provisioner/nebula.go

@@ -8,8 +8,10 @@ import (
 	"crypto/elliptic"
 	"crypto/x509"
 	"encoding/base64"
+	"encoding/pem"
 	"math/big"
 	"net"
+	"net/netip"
 	"time"
 
 	"github.com/pkg/errors"
@@ -48,7 +50,7 @@ type Nebula struct {
 	Roots   []byte   `json:"roots"`
 	Claims  *Claims  `json:"claims,omitempty"`
 	Options *Options `json:"options,omitempty"`
-	caPool  *nebula.NebulaCAPool
+	caPool  *nebula.CAPool
 	ctl     *Controller
 }
 
@@ -63,14 +65,10 @@ func (p *Nebula) Init(config Config) (err error) {
 		return errors.New("provisioner root(s) cannot be empty")
 	}
 
-	var certErrors []error
-	p.caPool, certErrors, err = nebula.NewCAPoolFromBytes(p.Roots)
+	p.caPool, err = nebula.NewCAPoolFromPEM(p.Roots)
 	if err != nil {
 		return errs.InternalServer("failed to create CA pool: %v", err)
 	}
-	if len(certErrors) > 0 {
-		return errs.InternalServer("failed to create CA pool: %v", certErrors)
-	}
 
 	config.Audiences = config.Audiences.WithFragment(p.GetIDForToken())
 	p.ctl, err = NewController(p, p.Claims, config, p.Options)
@@ -133,10 +131,11 @@ func (p *Nebula) AuthorizeSign(_ context.Context, token string) ([]SignOption, e
 
 	sans := claims.SANs
 	if len(sans) == 0 {
-		sans = make([]string, len(crt.Details.Ips)+1)
-		sans[0] = crt.Details.Name
-		for i, ipnet := range crt.Details.Ips {
-			sans[i+1] = ipnet.IP.String()
+		networks := crt.Networks()
+		sans = make([]string, len(networks)+1)
+		sans[0] = crt.Name()
+		for i, network := range networks {
+			sans[i+1] = network.Addr().String()
 		}
 	}
 
@@ -162,14 +161,14 @@ func (p *Nebula) AuthorizeSign(_ context.Context, token string) ([]SignOption, e
 		newProvisionerExtensionOption(TypeNebula, p.Name, "").WithControllerOptions(p.ctl),
 		profileLimitDuration{
 			def:       p.ctl.Claimer.DefaultTLSCertDuration(),
-			notBefore: crt.Details.NotBefore,
-			notAfter:  crt.Details.NotAfter,
+			notBefore: crt.NotBefore(),
+			notAfter:  crt.NotAfter(),
 		},
 		// validators
 		commonNameValidator(claims.Subject),
 		nebulaSANsValidator{
-			Name: crt.Details.Name,
-			IPs:  crt.Details.Ips,
+			Name:     crt.Name(),
+			Networks: crt.Networks(),
 		},
 		defaultPublicKeyValidator{},
 		newValidityValidator(p.ctl.Claimer.MinTLSCertDuration(), p.ctl.Claimer.MaxTLSCertDuration()),
@@ -192,10 +191,11 @@ func (p *Nebula) AuthorizeSSHSign(_ context.Context, token string) ([]SignOption
 
 	// Default template attributes.
 	keyID := claims.Subject
-	principals := make([]string, len(crt.Details.Ips)+1)
-	principals[0] = crt.Details.Name
-	for i, ipnet := range crt.Details.Ips {
-		principals[i+1] = ipnet.IP.String()
+	networks := crt.Networks()
+	principals := make([]string, len(networks)+1)
+	principals[0] = crt.Name()
+	for i, network := range networks {
+		principals[i+1] = network.Addr().String()
 	}
 
 	var signOptions []SignOption
@@ -206,8 +206,8 @@ func (p *Nebula) AuthorizeSSHSign(_ context.Context, token string) ([]SignOption
 
 		// Check that the token only contains valid principals.
 		v := nebulaPrincipalsValidator{
-			Name: crt.Details.Name,
-			IPs:  crt.Details.Ips,
+			Name:     crt.Name(),
+			Networks: crt.Networks(),
 		}
 		if err := v.Valid(*opts); err != nil {
 			return nil, err
@@ -264,7 +264,7 @@ func (p *Nebula) AuthorizeSSHSign(_ context.Context, token string) ([]SignOption
 		p,
 		templateOptions,
 		// Checks the validity bounds, and set the validity if has not been set.
-		&sshLimitDuration{p.ctl.Claimer, crt.Details.NotAfter},
+		&sshLimitDuration{p.ctl.Claimer, crt.NotAfter()},
 		// Validate public key.
 		&sshDefaultPublicKeyValidator{},
 		// Validate the validity period.
@@ -303,7 +303,7 @@ func (p *Nebula) AuthorizeSSHRekey(context.Context, string) (*ssh.Certificate, [
 	return nil, nil, errs.Unauthorized("nebula provisioner does not support SSH rekey")
 }
 
-func (p *Nebula) authorizeToken(token string, audiences []string) (*nebula.NebulaCertificate, *jwtPayload, error) {
+func (p *Nebula) authorizeToken(token string, audiences []string) (nebula.Certificate, *jwtPayload, error) {
 	jwt, err := jose.ParseSigned(token)
 	if err != nil {
 		return nil, nil, errs.UnauthorizedErr(err, errs.WithMessage("failed to parse token"))
@@ -322,24 +322,28 @@ func (p *Nebula) authorizeToken(token string, audiences []string) (*nebula.Nebul
 	if err != nil {
 		return nil, nil, errs.UnauthorizedErr(err, errs.WithMessage("failed to parse token: nebula header is not valid"))
 	}
-	c, err := nebula.UnmarshalNebulaCertificate(b)
+	// Wrap raw certificate bytes in PEM for unmarshaling. Try v1 banner
+	// first, then fall back to v2 if that fails.
+	pemData := pem.EncodeToMemory(&pem.Block{Type: nebula.CertificateBanner, Bytes: b})
+	c, _, err := nebula.UnmarshalCertificateFromPEM(pemData)
+	if err != nil {
+		pemData = pem.EncodeToMemory(&pem.Block{Type: nebula.CertificateV2Banner, Bytes: b})
+		c, _, err = nebula.UnmarshalCertificateFromPEM(pemData)
+	}
 	if err != nil {
 		return nil, nil, errs.UnauthorizedErr(err, errs.WithMessage("failed to parse nebula certificate: nebula header is not valid"))
 	}
 
 	// Validate nebula certificate against CAs
-	if valid, err := c.Verify(now(), p.caPool); !valid {
-		if err != nil {
-			return nil, nil, errs.UnauthorizedErr(err, errs.WithMessage("token is not valid: failed to verify certificate against configured CA"))
-		}
-		return nil, nil, errs.Unauthorized("token is not valid: failed to verify certificate against configured CA")
+	if _, err := p.caPool.VerifyCertificate(now(), c); err != nil {
+		return nil, nil, errs.UnauthorizedErr(err, errs.WithMessage("token is not valid: failed to verify certificate against configured CA"))
 	}
 
 	var pub any
 	switch {
-	case c.Details.Curve == nebula.Curve_P256:
+	case c.Curve() == nebula.Curve_P256:
 		// When Nebula is used with ECDSA P-256 keys, both CAs and clients use the same type.
-		ecdhPub, err := ecdh.P256().NewPublicKey(c.Details.PublicKey)
+		ecdhPub, err := ecdh.P256().NewPublicKey(c.PublicKey())
 		if err != nil {
 			return nil, nil, errs.UnauthorizedErr(err, errs.WithMessage("failed to parse nebula public key"))
 		}
@@ -349,10 +353,10 @@ func (p *Nebula) authorizeToken(token string, audiences []string) (*nebula.Nebul
 			X:     big.NewInt(0).SetBytes(publicKeyBytes[1:33]),
 			Y:     big.NewInt(0).SetBytes(publicKeyBytes[33:]),
 		}
-	case c.Details.IsCA:
-		pub = ed25519.PublicKey(c.Details.PublicKey)
+	case c.IsCA():
+		pub = ed25519.PublicKey(c.PublicKey())
 	default:
-		pub = x25519.PublicKey(c.Details.PublicKey)
+		pub = x25519.PublicKey(c.PublicKey())
 	}
 
 	// Validate token with public key
@@ -382,8 +386,8 @@ func (p *Nebula) authorizeToken(token string, audiences []string) (*nebula.Nebul
 }
 
 type nebulaSANsValidator struct {
-	Name string
-	IPs  []*net.IPNet
+	Name     string
+	Networks []netip.Prefix
 }
 
 // Valid verifies that the SANs stored in the validator are contained with those
@@ -417,16 +421,16 @@ func (v nebulaSANsValidator) Valid(req *x509.CertificateRequest) error {
 			}
 			// Check ip network
 			if !valid {
-				for _, ipNet := range v.IPs {
-					if ip.Equal(ipNet.IP) {
+				for _, network := range v.Networks {
+					if ip.Equal(net.IP(network.Addr().AsSlice())) {
 						valid = true
 						break
 					}
 				}
 			}
 			if !valid {
-				for _, ipNet := range v.IPs {
-					ips = append(ips, ipNet.IP)
+				for _, network := range v.Networks {
+					ips = append(ips, net.IP(network.Addr().AsSlice()))
 				}
 				return errs.Forbidden("certificate request contains invalid IP addresses - got %v, want %v", req.IPAddresses, ips)
 			}
@@ -437,8 +441,8 @@ func (v nebulaSANsValidator) Valid(req *x509.CertificateRequest) error {
 }
 
 type nebulaPrincipalsValidator struct {
-	Name string
-	IPs  []*net.IPNet
+	Name     string
+	Networks []netip.Prefix
 }
 
 // Valid checks that the SignSSHOptions principals contains only names in the
@@ -451,8 +455,8 @@ func (v nebulaPrincipalsValidator) Valid(got SignSSHOptions) error {
 		}
 		if !valid {
 			if ip := net.ParseIP(p); ip != nil {
-				for _, ipnet := range v.IPs {
-					if ip.Equal(ipnet.IP) {
+				for _, network := range v.Networks {
+					if ip.Equal(net.IP(network.Addr().AsSlice())) {
 						valid = true
 						break
 					}
@@ -461,9 +465,9 @@ func (v nebulaPrincipalsValidator) Valid(got SignSSHOptions) error {
 		}
 
 		if !valid {
-			ips := make([]net.IP, len(v.IPs))
-			for i, ipNet := range v.IPs {
-				ips[i] = ipNet.IP
+			ips := make([]net.IP, len(v.Networks))
+			for i, network := range v.Networks {
+				ips[i] = net.IP(network.Addr().AsSlice())
 			}
 			return errs.Forbidden(
 				"ssh certificate principals contains invalid name or IP addresses - got %v, want %s or %v",

+ 168 - 211
authority/provisioner/nebula_test.go

@@ -9,8 +9,8 @@ import (
 	"crypto/rand"
 	"crypto/x509"
 	"net"
+	"net/netip"
 	"net/url"
-	"reflect"
 	"strings"
 	"testing"
 	"time"
@@ -26,179 +26,144 @@ import (
 	"go.step.sm/crypto/x509util"
 )
 
-func mustNebulaIPNet(t *testing.T, s string) *net.IPNet {
+func mustNebulaPrefix(t *testing.T, s string) netip.Prefix {
 	t.Helper()
-	ip, ipNet, err := net.ParseCIDR(s)
+	p, err := netip.ParsePrefix(s)
 	require.NoError(t, err)
-	if ip = ip.To4(); ip == nil {
-		t.Fatalf("nebula only supports ipv4, have %s", s)
-	}
-	ipNet.IP = ip
-	return ipNet
+	return p
 }
 
-func mustNebulaCA(t *testing.T) (*cert.NebulaCertificate, ed25519.PrivateKey) {
+func mustNebulaCA(t *testing.T) (cert.Certificate, ed25519.PrivateKey) {
 	t.Helper()
 	pub, priv, err := ed25519.GenerateKey(rand.Reader)
 	require.NoError(t, err)
-	nc := &cert.NebulaCertificate{
-		Details: cert.NebulaCertificateDetails{
-			Name:   "TestCA",
-			Groups: []string{"test"},
-			Ips: []*net.IPNet{
-				mustNebulaIPNet(t, "10.1.0.0/16"),
-			},
-			Subnets:   []*net.IPNet{},
-			NotBefore: time.Now(),
-			NotAfter:  time.Now().Add(10 * time.Minute),
-			PublicKey: pub,
-			IsCA:      true,
-			Curve:     cert.Curve_CURVE25519,
-		},
-	}
-	err = nc.Sign(cert.Curve_CURVE25519, priv)
+	now := time.Now()
+	tbs := &cert.TBSCertificate{
+		Version:   cert.Version1,
+		Curve:     cert.Curve_CURVE25519,
+		Name:      "TestCA",
+		Groups:    []string{"test"},
+		Networks:  []netip.Prefix{netip.MustParsePrefix("10.1.0.0/16")},
+		NotBefore: time.Unix(now.Unix(), 0),
+		NotAfter:  time.Unix(now.Add(10*time.Minute).Unix(), 0),
+		PublicKey: pub,
+		IsCA:      true,
+	}
+	nc, err := tbs.Sign(nil, cert.Curve_CURVE25519, priv)
 	require.NoError(t, err)
 
 	return nc, priv
 }
 
-func mustExpiredNebulaCA(t *testing.T) (*cert.NebulaCertificate, ed25519.PrivateKey) {
+func mustExpiredNebulaCA(t *testing.T) (cert.Certificate, ed25519.PrivateKey) {
 	t.Helper()
 	pub, priv, err := ed25519.GenerateKey(rand.Reader)
 	require.NoError(t, err)
-	nc := &cert.NebulaCertificate{
-		Details: cert.NebulaCertificateDetails{
-			Name:   "ExpiredTestCA",
-			Groups: []string{"expired"},
-			Ips: []*net.IPNet{
-				mustNebulaIPNet(t, "10.2.0.0/16"),
-			},
-			Subnets:   []*net.IPNet{},
-			NotBefore: time.Now().Add(-2 * time.Hour),
-			NotAfter:  time.Now().Add(-1 * time.Hour),
-			PublicKey: pub,
-			IsCA:      true,
-			Curve:     cert.Curve_CURVE25519,
-		},
-	}
-	err = nc.Sign(cert.Curve_CURVE25519, priv)
+	now := time.Now()
+	tbs := &cert.TBSCertificate{
+		Version:   cert.Version1,
+		Curve:     cert.Curve_CURVE25519,
+		Name:      "ExpiredTestCA",
+		Groups:    []string{"expired"},
+		Networks:  []netip.Prefix{netip.MustParsePrefix("10.2.0.0/16")},
+		NotBefore: time.Unix(now.Add(-2*time.Hour).Unix(), 0),
+		NotAfter:  time.Unix(now.Add(-1*time.Hour).Unix(), 0),
+		PublicKey: pub,
+		IsCA:      true,
+	}
+	nc, err := tbs.Sign(nil, cert.Curve_CURVE25519, priv)
 	require.NoError(t, err)
 
 	return nc, priv
 }
 
-func mustNebulaP256CA(t *testing.T) (*cert.NebulaCertificate, *ecdsa.PrivateKey) {
+func mustNebulaP256CA(t *testing.T) (cert.Certificate, *ecdsa.PrivateKey) {
 	t.Helper()
 
 	key, err := ecdsa.GenerateKey(elliptic.P256(), rand.Reader)
 	require.NoError(t, err)
-	priv, err := key.ECDH()
+	ecdhPriv, err := key.ECDH()
 	require.NoError(t, err)
 
-	nc := &cert.NebulaCertificate{
-		Details: cert.NebulaCertificateDetails{
-			Name:   "TestCA",
-			Groups: []string{"test"},
-			Ips: []*net.IPNet{
-				mustNebulaIPNet(t, "10.1.0.0/16"),
-			},
-			Subnets:   []*net.IPNet{},
-			NotBefore: time.Now(),
-			NotAfter:  time.Now().Add(10 * time.Minute),
-			PublicKey: priv.PublicKey().Bytes(),
-			IsCA:      true,
-			Curve:     cert.Curve_P256,
-		},
-	}
-	err = nc.Sign(cert.Curve_P256, priv.Bytes())
+	now := time.Now()
+	tbs := &cert.TBSCertificate{
+		Version:   cert.Version1,
+		Curve:     cert.Curve_P256,
+		Name:      "TestCA",
+		Groups:    []string{"test"},
+		Networks:  []netip.Prefix{netip.MustParsePrefix("10.1.0.0/16")},
+		NotBefore: time.Unix(now.Unix(), 0),
+		NotAfter:  time.Unix(now.Add(10*time.Minute).Unix(), 0),
+		PublicKey: ecdhPriv.PublicKey().Bytes(),
+		IsCA:      true,
+	}
+
+	// For P256 CAs, Sign expects the raw 32-byte scalar as the key.
+	nc, err := tbs.Sign(nil, cert.Curve_P256, key.D.FillBytes(make([]byte, 32)))
 	require.NoError(t, err)
 	return nc, key
 }
 
-func mustNebulaCert(t *testing.T, name string, ipNet *net.IPNet, groups []string, ca *cert.NebulaCertificate, signer ed25519.PrivateKey) (*cert.NebulaCertificate, crypto.Signer) {
+func mustNebulaCert(t *testing.T, name string, network netip.Prefix, groups []string, ca cert.Certificate, signer ed25519.PrivateKey) (cert.Certificate, crypto.Signer) {
 	t.Helper()
 
 	pub, priv, err := x25519.GenerateKey(rand.Reader)
 	require.NoError(t, err)
 
-	issuer, err := ca.Sha256Sum()
-	require.NoError(t, err)
-
-	invertedGroups := make(map[string]struct{}, len(groups))
-	for _, name := range groups {
-		invertedGroups[name] = struct{}{}
-	}
-
 	t1 := time.Now().Truncate(time.Second)
-	nc := &cert.NebulaCertificate{
-		Details: cert.NebulaCertificateDetails{
-			Name:           name,
-			Ips:            []*net.IPNet{ipNet},
-			Subnets:        []*net.IPNet{},
-			Groups:         groups,
-			NotBefore:      t1,
-			NotAfter:       t1.Add(5 * time.Minute),
-			PublicKey:      pub,
-			IsCA:           false,
-			Issuer:         issuer,
-			InvertedGroups: invertedGroups,
-			Curve:          cert.Curve_CURVE25519,
-		},
-	}
-
-	err = nc.Sign(cert.Curve_CURVE25519, signer)
+	tbs := &cert.TBSCertificate{
+		Version:   cert.Version1,
+		Curve:     cert.Curve_CURVE25519,
+		Name:      name,
+		Networks:  []netip.Prefix{network},
+		Groups:    groups,
+		NotBefore: t1,
+		NotAfter:  t1.Add(5 * time.Minute),
+		PublicKey: pub,
+		IsCA:      false,
+	}
+
+	nc, err := tbs.Sign(ca, cert.Curve_CURVE25519, signer)
 	require.NoError(t, err)
 
 	return nc, priv
 }
 
-func mustNebulaP256Cert(t *testing.T, name string, ipNet *net.IPNet, groups []string, ca *cert.NebulaCertificate, signer *ecdsa.PrivateKey) (*cert.NebulaCertificate, crypto.Signer) {
+func mustNebulaP256Cert(t *testing.T, name string, network netip.Prefix, groups []string, ca cert.Certificate, signer *ecdsa.PrivateKey) (cert.Certificate, crypto.Signer) {
 	t.Helper()
 
 	key, err := ecdsa.GenerateKey(elliptic.P256(), rand.Reader)
 	require.NoError(t, err)
-	priv, err := key.ECDH()
+	ecdhPriv, err := key.ECDH()
 	require.NoError(t, err)
 
-	issuer, err := ca.Sha256Sum()
-	require.NoError(t, err)
-
-	invertedGroups := make(map[string]struct{}, len(groups))
-	for _, name := range groups {
-		invertedGroups[name] = struct{}{}
-	}
-
 	t1 := time.Now().Truncate(time.Second)
-	nc := &cert.NebulaCertificate{
-		Details: cert.NebulaCertificateDetails{
-			Name:           name,
-			Ips:            []*net.IPNet{ipNet},
-			Subnets:        []*net.IPNet{},
-			Groups:         groups,
-			NotBefore:      t1,
-			NotAfter:       t1.Add(5 * time.Minute),
-			PublicKey:      priv.PublicKey().Bytes(),
-			IsCA:           false,
-			Issuer:         issuer,
-			InvertedGroups: invertedGroups,
-			Curve:          cert.Curve_P256,
-		},
-	}
-
-	ecdhKey, err := signer.ECDH()
+	tbs := &cert.TBSCertificate{
+		Version:   cert.Version1,
+		Curve:     cert.Curve_P256,
+		Name:      name,
+		Networks:  []netip.Prefix{network},
+		Groups:    groups,
+		NotBefore: t1,
+		NotAfter:  t1.Add(5 * time.Minute),
+		PublicKey: ecdhPriv.PublicKey().Bytes(),
+		IsCA:      false,
+	}
+
+	ecdhSigner, err := signer.ECDH()
 	require.NoError(t, err)
 
-	err = nc.Sign(cert.Curve_P256, ecdhKey.Bytes())
+	nc, err := tbs.Sign(ca, cert.Curve_P256, ecdhSigner.Bytes())
 	require.NoError(t, err)
 
 	return nc, key
 }
 
-func mustNebulaProvisioner(t *testing.T) (*Nebula, *cert.NebulaCertificate, ed25519.PrivateKey) {
+func mustNebulaProvisioner(t *testing.T) (*Nebula, cert.Certificate, ed25519.PrivateKey) {
 	t.Helper()
 
 	nc, signer := mustNebulaCA(t)
-	ncPem, err := nc.MarshalToPEM()
+	ncPem, err := nc.MarshalPEM()
 	require.NoError(t, err)
 	bTrue := true
 	p := &Nebula{
@@ -218,11 +183,11 @@ func mustNebulaProvisioner(t *testing.T) (*Nebula, *cert.NebulaCertificate, ed25
 	return p, nc, signer
 }
 
-func mustNebulaP256Provisioner(t *testing.T) (*Nebula, *cert.NebulaCertificate, *ecdsa.PrivateKey) {
+func mustNebulaP256Provisioner(t *testing.T) (*Nebula, cert.Certificate, *ecdsa.PrivateKey) {
 	t.Helper()
 
 	nc, signer := mustNebulaP256CA(t)
-	ncPem, err := nc.MarshalToPEM()
+	ncPem, err := nc.MarshalPEM()
 	require.NoError(t, err)
 	bTrue := true
 	p := &Nebula{
@@ -242,7 +207,7 @@ func mustNebulaP256Provisioner(t *testing.T) (*Nebula, *cert.NebulaCertificate,
 	return p, nc, signer
 }
 
-func mustNebulaToken(t *testing.T, sub, iss, aud string, iat time.Time, sans []string, nc *cert.NebulaCertificate, key crypto.Signer, algorithm jose.SignatureAlgorithm) string {
+func mustNebulaToken(t *testing.T, sub, iss, aud string, iat time.Time, sans []string, nc cert.Certificate, key crypto.Signer, algorithm jose.SignatureAlgorithm) string {
 	t.Helper()
 	ncDer, err := nc.Marshal()
 	require.NoError(t, err)
@@ -278,7 +243,7 @@ func mustNebulaToken(t *testing.T, sub, iss, aud string, iat time.Time, sans []s
 	return tok
 }
 
-func mustNebulaSSHToken(t *testing.T, sub, iss, aud string, iat time.Time, opts *SignSSHOptions, nc *cert.NebulaCertificate, key crypto.Signer, algorithm jose.SignatureAlgorithm) string {
+func mustNebulaSSHToken(t *testing.T, sub, iss, aud string, iat time.Time, opts *SignSSHOptions, nc cert.Certificate, key crypto.Signer, algorithm jose.SignatureAlgorithm) string {
 	t.Helper()
 	ncDer, err := nc.Marshal()
 	require.NoError(t, err)
@@ -321,10 +286,10 @@ func mustNebulaSSHToken(t *testing.T, sub, iss, aud string, iat time.Time, opts
 
 func TestNebula_Init(t *testing.T) {
 	nc, _ := mustNebulaCA(t)
-	ncPem, err := nc.MarshalToPEM()
+	ncPem, err := nc.MarshalPEM()
 	require.NoError(t, err)
 	expiredNC, _ := mustExpiredNebulaCA(t)
-	expiredPEM, err := expiredNC.MarshalToPEM()
+	expiredPEM, err := expiredNC.MarshalPEM()
 	require.NoError(t, err)
 	expiredPEM = append(expiredPEM, ncPem...) // needed so that regular error isn't triggered
 
@@ -428,7 +393,7 @@ func TestNebula_GetIDForToken(t *testing.T) {
 
 func TestNebula_GetTokenID(t *testing.T) {
 	p, ca, signer := mustNebulaProvisioner(t)
-	c1, priv := mustNebulaCert(t, "test.lan", mustNebulaIPNet(t, "10.1.0.1/16"), []string{"group"}, ca, signer)
+	c1, priv := mustNebulaCert(t, "test.lan", mustNebulaPrefix(t, "10.1.0.1/16"), []string{"test"}, ca, signer)
 	t1 := mustNebulaToken(t, "test.lan", p.Name, p.ctl.Audiences.Sign[0], now(), []string{"test.lan", "10.1.0.1"}, c1, priv, jose.XEdDSA)
 	_, claims, err := parseToken(t1)
 	require.NoError(t, err)
@@ -540,7 +505,7 @@ func TestNebula_GetEncryptedKey(t *testing.T) {
 func TestNebula_AuthorizeSign(t *testing.T) {
 	ctx := context.TODO()
 	p, ca, signer := mustNebulaProvisioner(t)
-	crt, priv := mustNebulaCert(t, "test.lan", mustNebulaIPNet(t, "10.1.0.1/16"), []string{"test"}, ca, signer)
+	crt, priv := mustNebulaCert(t, "test.lan", mustNebulaPrefix(t, "10.1.0.1/16"), []string{"test"}, ca, signer)
 	ok := mustNebulaToken(t, "test.lan", p.Name, p.ctl.Audiences.Sign[0], now(), []string{"test.lan", "10.1.0.1"}, crt, priv, jose.XEdDSA)
 	okNoSANs := mustNebulaToken(t, "test.lan", p.Name, p.ctl.Audiences.Sign[0], now(), nil, crt, priv, jose.XEdDSA)
 
@@ -582,7 +547,7 @@ func TestNebula_AuthorizeSSHSign(t *testing.T) {
 	ctx := context.TODO()
 	// Ok provisioner
 	p, ca, signer := mustNebulaProvisioner(t)
-	crt, priv := mustNebulaCert(t, "test.lan", mustNebulaIPNet(t, "10.1.0.1/16"), []string{"test"}, ca, signer)
+	crt, priv := mustNebulaCert(t, "test.lan", mustNebulaPrefix(t, "10.1.0.1/16"), []string{"test"}, ca, signer)
 	ok := mustNebulaSSHToken(t, "test.lan", p.Name, p.ctl.Audiences.SSHSign[0], now(), &SignSSHOptions{
 		CertType:   "host",
 		KeyID:      "test.lan",
@@ -691,12 +656,12 @@ func TestNebula_AuthorizeRevoke(t *testing.T) {
 	ctx := context.TODO()
 	// Ok provisioner
 	p, ca, signer := mustNebulaProvisioner(t)
-	crt, priv := mustNebulaCert(t, "test.lan", mustNebulaIPNet(t, "10.1.0.1/16"), []string{"test"}, ca, signer)
+	crt, priv := mustNebulaCert(t, "test.lan", mustNebulaPrefix(t, "10.1.0.1/16"), []string{"test"}, ca, signer)
 	ok := mustNebulaToken(t, "test.lan", p.Name, p.ctl.Audiences.Revoke[0], now(), nil, crt, priv, jose.XEdDSA)
 
 	// Fail different CA
 	nc, signer := mustNebulaCA(t)
-	crt, priv = mustNebulaCert(t, "test.lan", mustNebulaIPNet(t, "10.1.0.1/16"), []string{"test"}, nc, signer)
+	crt, priv = mustNebulaCert(t, "test.lan", mustNebulaPrefix(t, "10.1.0.1/16"), []string{"test"}, nc, signer)
 	failToken := mustNebulaToken(t, "test.lan", p.Name, p.ctl.Audiences.Revoke[0], now(), nil, crt, priv, jose.XEdDSA)
 
 	type args struct {
@@ -725,12 +690,12 @@ func TestNebula_AuthorizeSSHRevoke(t *testing.T) {
 	ctx := context.TODO()
 	// Ok provisioner
 	p, ca, signer := mustNebulaProvisioner(t)
-	crt, priv := mustNebulaCert(t, "test.lan", mustNebulaIPNet(t, "10.1.0.1/16"), []string{"test"}, ca, signer)
+	crt, priv := mustNebulaCert(t, "test.lan", mustNebulaPrefix(t, "10.1.0.1/16"), []string{"test"}, ca, signer)
 	ok := mustNebulaSSHToken(t, "test.lan", p.Name, p.ctl.Audiences.SSHRevoke[0], now(), nil, crt, priv, jose.XEdDSA)
 
 	// Fail different CA
 	nc, signer := mustNebulaCA(t)
-	crt, priv = mustNebulaCert(t, "test.lan", mustNebulaIPNet(t, "10.1.0.1/16"), []string{"test"}, nc, signer)
+	crt, priv = mustNebulaCert(t, "test.lan", mustNebulaPrefix(t, "10.1.0.1/16"), []string{"test"}, nc, signer)
 	failToken := mustNebulaSSHToken(t, "test.lan", p.Name, p.ctl.Audiences.SSHRevoke[0], now(), nil, crt, priv, jose.XEdDSA)
 
 	// Provisioner with SSH disabled
@@ -764,7 +729,7 @@ func TestNebula_AuthorizeSSHRevoke(t *testing.T) {
 
 func TestNebula_AuthorizeSSHRenew(t *testing.T) {
 	p, ca, signer := mustNebulaProvisioner(t)
-	crt, priv := mustNebulaCert(t, "test.lan", mustNebulaIPNet(t, "10.1.0.1/16"), []string{"test"}, ca, signer)
+	crt, priv := mustNebulaCert(t, "test.lan", mustNebulaPrefix(t, "10.1.0.1/16"), []string{"test"}, ca, signer)
 	t1 := mustNebulaSSHToken(t, "test.lan", p.Name, p.ctl.Audiences.SSHRenew[0], now(), nil, crt, priv, jose.XEdDSA)
 
 	type args struct {
@@ -787,16 +752,14 @@ func TestNebula_AuthorizeSSHRenew(t *testing.T) {
 				t.Errorf("Nebula.AuthorizeSSHRenew() error = %v, wantErr %v", err, tt.wantErr)
 				return
 			}
-			if !reflect.DeepEqual(got, tt.want) {
-				t.Errorf("Nebula.AuthorizeSSHRenew() = %v, want %v", got, tt.want)
-			}
+			assert.Equal(t, tt.want, got)
 		})
 	}
 }
 
 func TestNebula_AuthorizeSSHRekey(t *testing.T) {
 	p, ca, signer := mustNebulaProvisioner(t)
-	crt, priv := mustNebulaCert(t, "test.lan", mustNebulaIPNet(t, "10.1.0.1/16"), []string{"test"}, ca, signer)
+	crt, priv := mustNebulaCert(t, "test.lan", mustNebulaPrefix(t, "10.1.0.1/16"), []string{"test"}, ca, signer)
 	t1 := mustNebulaSSHToken(t, "test.lan", p.Name, p.ctl.Audiences.SSHRekey[0], now(), nil, crt, priv, jose.XEdDSA)
 
 	type args struct {
@@ -820,12 +783,8 @@ func TestNebula_AuthorizeSSHRekey(t *testing.T) {
 				t.Errorf("Nebula.AuthorizeSSHRekey() error = %v, wantErr %v", err, tt.wantErr)
 				return
 			}
-			if !reflect.DeepEqual(got, tt.want) {
-				t.Errorf("Nebula.AuthorizeSSHRekey() got = %v, want %v", got, tt.want)
-			}
-			if !reflect.DeepEqual(got1, tt.want1) {
-				t.Errorf("Nebula.AuthorizeSSHRekey() got1 = %v, want %v", got1, tt.want1)
-			}
+			assert.Equal(t, tt.want, got)
+			assert.Equal(t, tt.want1, got1)
 		})
 	}
 }
@@ -833,7 +792,7 @@ func TestNebula_AuthorizeSSHRekey(t *testing.T) {
 func TestNebula_authorizeToken(t *testing.T) {
 	t1 := now()
 	p, ca, signer := mustNebulaProvisioner(t)
-	crt, priv := mustNebulaCert(t, "test.lan", mustNebulaIPNet(t, "10.1.0.1/16"), []string{"test"}, ca, signer)
+	crt, priv := mustNebulaCert(t, "test.lan", mustNebulaPrefix(t, "10.1.0.1/16"), []string{"test"}, ca, signer)
 	ok := mustNebulaToken(t, "test.lan", p.Name, p.ctl.Audiences.Sign[0], t1, []string{"10.1.0.1"}, crt, priv, jose.XEdDSA)
 	okNoSANs := mustNebulaToken(t, "test.lan", p.Name, p.ctl.Audiences.Sign[0], t1, nil, crt, priv, jose.XEdDSA)
 	okSSH := mustNebulaSSHToken(t, "test.lan", p.Name, p.ctl.Audiences.SSHSign[0], t1, &SignSSHOptions{
@@ -882,21 +841,20 @@ func TestNebula_authorizeToken(t *testing.T) {
 		audiences []string
 	}
 	tests := []struct {
-		name    string
-		p       *Nebula
-		args    args
-		want    *cert.NebulaCertificate
-		want1   *jwtPayload
-		wantErr bool
+		name       string
+		p          *Nebula
+		args       args
+		wantClaims *jwtPayload
+		wantErr    bool
 	}{
-		{"ok x509", p, args{ok, p.ctl.Audiences.Sign}, crt, &jwtPayload{
+		{"ok x509", p, args{ok, p.ctl.Audiences.Sign}, &jwtPayload{
 			Claims: x509Claims,
 			SANs:   []string{"10.1.0.1"},
 		}, false},
-		{"ok x509 no sans", p, args{okNoSANs, p.ctl.Audiences.Sign}, crt, &jwtPayload{
+		{"ok x509 no sans", p, args{okNoSANs, p.ctl.Audiences.Sign}, &jwtPayload{
 			Claims: x509Claims,
 		}, false},
-		{"ok ssh", p, args{okSSH, p.ctl.Audiences.SSHSign}, crt, &jwtPayload{
+		{"ok ssh", p, args{okSSH, p.ctl.Audiences.SSHSign}, &jwtPayload{
 			Claims: sshClaims,
 			Step: &stepPayload{
 				SSH: &SignSSHOptions{
@@ -906,16 +864,16 @@ func TestNebula_authorizeToken(t *testing.T) {
 				},
 			},
 		}, false},
-		{"ok ssh no principals", p, args{okSSHNoOptions, p.ctl.Audiences.SSHSign}, crt, &jwtPayload{
+		{"ok ssh no principals", p, args{okSSHNoOptions, p.ctl.Audiences.SSHSign}, &jwtPayload{
 			Claims: sshClaims,
 		}, false},
-		{"fail parse", p, args{"bad.token", p.ctl.Audiences.Sign}, nil, nil, true},
-		{"fail header", p, args{simpleToken, p.ctl.Audiences.Sign}, nil, nil, true},
-		{"fail verify", p2, args{ok, p.ctl.Audiences.Sign}, nil, nil, true},
-		{"fail claims nbf", p, args{failNotBefore, p.ctl.Audiences.Sign}, nil, nil, true},
-		{"fail claims iss", p, args{failIssuer, p.ctl.Audiences.Sign}, nil, nil, true},
-		{"fail claims aud", p, args{failAudience, p.ctl.Audiences.Sign}, nil, nil, true},
-		{"fail claims sub", p, args{failSubject, p.ctl.Audiences.Sign}, nil, nil, true},
+		{"fail parse", p, args{"bad.token", p.ctl.Audiences.Sign}, nil, true},
+		{"fail header", p, args{simpleToken, p.ctl.Audiences.Sign}, nil, true},
+		{"fail verify", p2, args{ok, p.ctl.Audiences.Sign}, nil, true},
+		{"fail claims nbf", p, args{failNotBefore, p.ctl.Audiences.Sign}, nil, true},
+		{"fail claims iss", p, args{failIssuer, p.ctl.Audiences.Sign}, nil, true},
+		{"fail claims aud", p, args{failAudience, p.ctl.Audiences.Sign}, nil, true},
+		{"fail claims sub", p, args{failSubject, p.ctl.Audiences.Sign}, nil, true},
 	}
 	for _, tt := range tests {
 		t.Run(tt.name, func(t *testing.T) {
@@ -927,13 +885,13 @@ func TestNebula_authorizeToken(t *testing.T) {
 				return
 			}
 
-			if got1 != nil && tt.want1 != nil {
-				tt.want1.ID = got1.ID
+			if got1 != nil && tt.wantClaims != nil {
+				tt.wantClaims.ID = got1.ID
 			}
 
 			assert.NoError(t, err)
-			assert.Equal(t, tt.want, got)
-			assert.Equal(t, tt.want1, got1)
+			assert.NotNil(t, got)
+			assert.Equal(t, tt.wantClaims, got1)
 		})
 	}
 }
@@ -941,7 +899,7 @@ func TestNebula_authorizeToken(t *testing.T) {
 func TestNebula_authorizeToken_P256(t *testing.T) {
 	t1 := now()
 	p, ca, signer := mustNebulaP256Provisioner(t)
-	crt, priv := mustNebulaP256Cert(t, "test.lan", mustNebulaIPNet(t, "10.1.0.1/16"), []string{"test"}, ca, signer)
+	crt, priv := mustNebulaP256Cert(t, "test.lan", mustNebulaPrefix(t, "10.1.0.1/16"), []string{"test"}, ca, signer)
 	ok := mustNebulaToken(t, "test.lan", p.Name, p.ctl.Audiences.Sign[0], t1, []string{"10.1.0.1"}, crt, priv, jose.ES256)
 	okNoSANs := mustNebulaToken(t, "test.lan", p.Name, p.ctl.Audiences.Sign[0], t1, nil, crt, priv, jose.ES256)
 	okSSH := mustNebulaSSHToken(t, "test.lan", p.Name, p.ctl.Audiences.SSHSign[0], t1, &SignSSHOptions{
@@ -990,21 +948,20 @@ func TestNebula_authorizeToken_P256(t *testing.T) {
 		audiences []string
 	}
 	tests := []struct {
-		name    string
-		p       *Nebula
-		args    args
-		want    *cert.NebulaCertificate
-		want1   *jwtPayload
-		wantErr bool
+		name       string
+		p          *Nebula
+		args       args
+		wantClaims *jwtPayload
+		wantErr    bool
 	}{
-		{"ok x509", p, args{ok, p.ctl.Audiences.Sign}, crt, &jwtPayload{
+		{"ok x509", p, args{ok, p.ctl.Audiences.Sign}, &jwtPayload{
 			Claims: x509Claims,
 			SANs:   []string{"10.1.0.1"},
 		}, false},
-		{"ok x509 no sans", p, args{okNoSANs, p.ctl.Audiences.Sign}, crt, &jwtPayload{
+		{"ok x509 no sans", p, args{okNoSANs, p.ctl.Audiences.Sign}, &jwtPayload{
 			Claims: x509Claims,
 		}, false},
-		{"ok ssh", p, args{okSSH, p.ctl.Audiences.SSHSign}, crt, &jwtPayload{
+		{"ok ssh", p, args{okSSH, p.ctl.Audiences.SSHSign}, &jwtPayload{
 			Claims: sshClaims,
 			Step: &stepPayload{
 				SSH: &SignSSHOptions{
@@ -1014,16 +971,16 @@ func TestNebula_authorizeToken_P256(t *testing.T) {
 				},
 			},
 		}, false},
-		{"ok ssh no principals", p, args{okSSHNoOptions, p.ctl.Audiences.SSHSign}, crt, &jwtPayload{
+		{"ok ssh no principals", p, args{okSSHNoOptions, p.ctl.Audiences.SSHSign}, &jwtPayload{
 			Claims: sshClaims,
 		}, false},
-		{"fail parse", p, args{"bad.token", p.ctl.Audiences.Sign}, nil, nil, true},
-		{"fail header", p, args{simpleToken, p.ctl.Audiences.Sign}, nil, nil, true},
-		{"fail verify", p2, args{ok, p.ctl.Audiences.Sign}, nil, nil, true},
-		{"fail claims nbf", p, args{failNotBefore, p.ctl.Audiences.Sign}, nil, nil, true},
-		{"fail claims iss", p, args{failIssuer, p.ctl.Audiences.Sign}, nil, nil, true},
-		{"fail claims aud", p, args{failAudience, p.ctl.Audiences.Sign}, nil, nil, true},
-		{"fail claims sub", p, args{failSubject, p.ctl.Audiences.Sign}, nil, nil, true},
+		{"fail parse", p, args{"bad.token", p.ctl.Audiences.Sign}, nil, true},
+		{"fail header", p, args{simpleToken, p.ctl.Audiences.Sign}, nil, true},
+		{"fail verify", p2, args{ok, p.ctl.Audiences.Sign}, nil, true},
+		{"fail claims nbf", p, args{failNotBefore, p.ctl.Audiences.Sign}, nil, true},
+		{"fail claims iss", p, args{failIssuer, p.ctl.Audiences.Sign}, nil, true},
+		{"fail claims aud", p, args{failAudience, p.ctl.Audiences.Sign}, nil, true},
+		{"fail claims sub", p, args{failSubject, p.ctl.Audiences.Sign}, nil, true},
 	}
 	for _, tt := range tests {
 		t.Run(tt.name, func(t *testing.T) {
@@ -1035,22 +992,22 @@ func TestNebula_authorizeToken_P256(t *testing.T) {
 				return
 			}
 
-			if got1 != nil && tt.want1 != nil {
-				tt.want1.ID = got1.ID
+			if got1 != nil && tt.wantClaims != nil {
+				tt.wantClaims.ID = got1.ID
 			}
 
 			assert.NoError(t, err)
-			assert.Equal(t, tt.want, got)
-			assert.Equal(t, tt.want1, got1)
+			assert.NotNil(t, got)
+			assert.Equal(t, tt.wantClaims, got1)
 		})
 	}
 }
 
 func Test_nebulaSANsValidator_Valid(t *testing.T) {
-	ipNet := mustNebulaIPNet(t, "10.1.2.3/16")
+	prefix := mustNebulaPrefix(t, "10.1.2.3/16")
 	type fields struct {
-		Name string
-		IPs  []*net.IPNet
+		Name     string
+		Networks []netip.Prefix
 	}
 	type args struct {
 		req *x509.CertificateRequest
@@ -1061,47 +1018,47 @@ func Test_nebulaSANsValidator_Valid(t *testing.T) {
 		args    args
 		wantErr bool
 	}{
-		{"ok", fields{"dns.name", []*net.IPNet{ipNet}}, args{&x509.CertificateRequest{
+		{"ok", fields{"dns.name", []netip.Prefix{prefix}}, args{&x509.CertificateRequest{
 			DNSNames:    []string{"dns.name"},
 			IPAddresses: []net.IP{net.IPv4(10, 1, 2, 3)},
 		}}, false},
-		{"ok name only", fields{"dns.name", []*net.IPNet{ipNet}}, args{&x509.CertificateRequest{
+		{"ok name only", fields{"dns.name", []netip.Prefix{prefix}}, args{&x509.CertificateRequest{
 			DNSNames: []string{"dns.name"},
 		}}, false},
-		{"ok ip only", fields{"dns.name", []*net.IPNet{ipNet}}, args{&x509.CertificateRequest{
+		{"ok ip only", fields{"dns.name", []netip.Prefix{prefix}}, args{&x509.CertificateRequest{
 			IPAddresses: []net.IP{net.IPv4(10, 1, 2, 3)},
 		}}, false},
-		{"ok email name", fields{"jane@doe.org", []*net.IPNet{ipNet}}, args{&x509.CertificateRequest{
+		{"ok email name", fields{"jane@doe.org", []netip.Prefix{prefix}}, args{&x509.CertificateRequest{
 			EmailAddresses: []string{"jane@doe.org"},
 			IPAddresses:    []net.IP{net.IPv4(10, 1, 2, 3)},
 		}}, false},
-		{"ok uri name", fields{"urn:foobar", []*net.IPNet{ipNet}}, args{&x509.CertificateRequest{
+		{"ok uri name", fields{"urn:foobar", []netip.Prefix{prefix}}, args{&x509.CertificateRequest{
 			URIs:        []*url.URL{{Scheme: "urn", Opaque: "foobar"}},
 			IPAddresses: []net.IP{net.IPv4(10, 1, 2, 3)},
 		}}, false},
-		{"ok ip name", fields{"127.0.0.1", []*net.IPNet{ipNet}}, args{&x509.CertificateRequest{
+		{"ok ip name", fields{"127.0.0.1", []netip.Prefix{prefix}}, args{&x509.CertificateRequest{
 			IPAddresses: []net.IP{net.IPv4(127, 0, 0, 1), net.IPv4(10, 1, 2, 3)},
 		}}, false},
-		{"ok multiple ips", fields{"dns.name", []*net.IPNet{ipNet, mustNebulaIPNet(t, "10.2.2.3/8")}}, args{&x509.CertificateRequest{
+		{"ok multiple ips", fields{"dns.name", []netip.Prefix{prefix, mustNebulaPrefix(t, "10.2.2.3/8")}}, args{&x509.CertificateRequest{
 			DNSNames:    []string{"dns.name"},
 			IPAddresses: []net.IP{net.IPv4(10, 1, 2, 3), net.IPv4(10, 2, 2, 3)},
 		}}, false},
-		{"fail dns", fields{"fail.name", []*net.IPNet{ipNet}}, args{&x509.CertificateRequest{
+		{"fail dns", fields{"fail.name", []netip.Prefix{prefix}}, args{&x509.CertificateRequest{
 			DNSNames:    []string{"dns.name"},
 			IPAddresses: []net.IP{net.IPv4(10, 1, 2, 3)},
 		}}, true},
-		{"fail email", fields{"fail@doe.org", []*net.IPNet{ipNet}}, args{&x509.CertificateRequest{
+		{"fail email", fields{"fail@doe.org", []netip.Prefix{prefix}}, args{&x509.CertificateRequest{
 			EmailAddresses: []string{"jane@doe.org"},
 			IPAddresses:    []net.IP{net.IPv4(10, 1, 2, 3)},
 		}}, true},
-		{"fail uri", fields{"urn:barfoo", []*net.IPNet{ipNet}}, args{&x509.CertificateRequest{
+		{"fail uri", fields{"urn:barfoo", []netip.Prefix{prefix}}, args{&x509.CertificateRequest{
 			URIs:        []*url.URL{{Scheme: "urn", Opaque: "foobar"}},
 			IPAddresses: []net.IP{net.IPv4(10, 1, 2, 3)},
 		}}, true},
-		{"fail ip", fields{"127.0.0.1", []*net.IPNet{ipNet}}, args{&x509.CertificateRequest{
+		{"fail ip", fields{"127.0.0.1", []netip.Prefix{prefix}}, args{&x509.CertificateRequest{
 			IPAddresses: []net.IP{net.IPv4(10, 1, 2, 1), net.IPv4(10, 1, 2, 3)},
 		}}, true},
-		{"fail nebula ip", fields{"dns.name", []*net.IPNet{ipNet}}, args{&x509.CertificateRequest{
+		{"fail nebula ip", fields{"dns.name", []netip.Prefix{prefix}}, args{&x509.CertificateRequest{
 			DNSNames:    []string{"dns.name"},
 			IPAddresses: []net.IP{net.IPv4(10, 2, 2, 3)},
 		}}, true},
@@ -1109,8 +1066,8 @@ func Test_nebulaSANsValidator_Valid(t *testing.T) {
 	for _, tt := range tests {
 		t.Run(tt.name, func(t *testing.T) {
 			v := nebulaSANsValidator{
-				Name: tt.fields.Name,
-				IPs:  tt.fields.IPs,
+				Name:     tt.fields.Name,
+				Networks: tt.fields.Networks,
 			}
 			if err := v.Valid(tt.args.req); (err != nil) != tt.wantErr {
 				t.Errorf("nebulaSANsValidator.Valid() error = %v, wantErr %v", err, tt.wantErr)
@@ -1120,11 +1077,11 @@ func Test_nebulaSANsValidator_Valid(t *testing.T) {
 }
 
 func Test_nebulaPrincipalsValidator_Valid(t *testing.T) {
-	ipNet := mustNebulaIPNet(t, "10.1.2.3/16")
+	prefix := mustNebulaPrefix(t, "10.1.2.3/16")
 
 	type fields struct {
-		Name string
-		IPs  []*net.IPNet
+		Name     string
+		Networks []netip.Prefix
 	}
 	type args struct {
 		got SignSSHOptions
@@ -1135,27 +1092,27 @@ func Test_nebulaPrincipalsValidator_Valid(t *testing.T) {
 		args    args
 		wantErr bool
 	}{
-		{"ok", fields{"dns.name", []*net.IPNet{ipNet}}, args{SignSSHOptions{
+		{"ok", fields{"dns.name", []netip.Prefix{prefix}}, args{SignSSHOptions{
 			Principals: []string{"dns.name", "10.1.2.3"},
 		}}, false},
-		{"ok name", fields{"dns.name", []*net.IPNet{ipNet}}, args{SignSSHOptions{
+		{"ok name", fields{"dns.name", []netip.Prefix{prefix}}, args{SignSSHOptions{
 			Principals: []string{"dns.name"},
 		}}, false},
-		{"ok ip", fields{"dns.name", []*net.IPNet{ipNet}}, args{SignSSHOptions{
+		{"ok ip", fields{"dns.name", []netip.Prefix{prefix}}, args{SignSSHOptions{
 			Principals: []string{"10.1.2.3"},
 		}}, false},
-		{"fail name", fields{"dns.name", []*net.IPNet{ipNet}}, args{SignSSHOptions{
+		{"fail name", fields{"dns.name", []netip.Prefix{prefix}}, args{SignSSHOptions{
 			Principals: []string{"foo.name", "10.1.2.3"},
 		}}, true},
-		{"fail ip", fields{"dns.name", []*net.IPNet{ipNet}}, args{SignSSHOptions{
+		{"fail ip", fields{"dns.name", []netip.Prefix{prefix}}, args{SignSSHOptions{
 			Principals: []string{"dns.name", "10.2.2.3"},
 		}}, true},
 	}
 	for _, tt := range tests {
 		t.Run(tt.name, func(t *testing.T) {
 			v := nebulaPrincipalsValidator{
-				Name: tt.fields.Name,
-				IPs:  tt.fields.IPs,
+				Name:     tt.fields.Name,
+				Networks: tt.fields.Networks,
 			}
 			if err := v.Valid(tt.args.got); (err != nil) != tt.wantErr {
 				t.Errorf("nebulaPrincipalsValidator.Valid() error = %v, wantErr %v", err, tt.wantErr)

+ 11 - 10
go.mod

@@ -1,6 +1,6 @@
 module github.com/smallstep/certificates
 
-go 1.24.0
+go 1.25
 
 require (
 	cloud.google.com/go/longrunning v0.8.0
@@ -27,7 +27,7 @@ require (
 	github.com/prometheus/client_golang v1.23.2
 	github.com/rs/xid v1.6.0
 	github.com/sirupsen/logrus v1.9.4
-	github.com/slackhq/nebula v1.9.7
+	github.com/slackhq/nebula v1.10.3
 	github.com/smallstep/assert v0.0.0-20200723003110-82e2b9b3b262
 	github.com/smallstep/cli-utils v0.12.2
 	github.com/smallstep/go-attestation v0.4.4-0.20241119153605-2306d5b464ca
@@ -40,7 +40,7 @@ require (
 	go.step.sm/crypto v0.76.0
 	go.uber.org/mock v0.6.0
 	golang.org/x/crypto v0.48.0
-	golang.org/x/net v0.49.0
+	golang.org/x/net v0.50.0
 	golang.org/x/sync v0.19.0
 	google.golang.org/api v0.265.0
 	google.golang.org/grpc v1.78.0
@@ -54,7 +54,8 @@ require (
 	cloud.google.com/go/compute/metadata v0.9.0 // indirect
 	cloud.google.com/go/iam v1.5.3 // indirect
 	cloud.google.com/go/kms v1.25.0 // indirect
-	dario.cat/mergo v1.0.1 // indirect
+	dario.cat/mergo v1.0.2 // indirect
+	filippo.io/bigmod v0.1.0 // indirect
 	filippo.io/edwards25519 v1.1.0 // indirect
 	github.com/AndreasBriese/bbloom v0.0.0-20190825152654-46b345b51c96 // indirect
 	github.com/Azure/azure-sdk-for-go/sdk/azcore v1.21.0 // indirect
@@ -133,7 +134,7 @@ require (
 	github.com/mattn/go-colorable v0.1.14 // indirect
 	github.com/mattn/go-isatty v0.0.20 // indirect
 	github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d // indirect
-	github.com/miekg/pkcs11 v1.1.1 // indirect
+	github.com/miekg/pkcs11 v1.1.2 // indirect
 	github.com/mitchellh/copystructure v1.2.0 // indirect
 	github.com/mitchellh/go-homedir v1.1.0 // indirect
 	github.com/mitchellh/mapstructure v1.5.0 // indirect
@@ -143,8 +144,8 @@ require (
 	github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect
 	github.com/pmezard/go-difflib v1.0.0 // indirect
 	github.com/prometheus/client_model v0.6.2 // indirect
-	github.com/prometheus/common v0.66.1 // indirect
-	github.com/prometheus/procfs v0.16.1 // indirect
+	github.com/prometheus/common v0.67.5 // indirect
+	github.com/prometheus/procfs v0.19.2 // indirect
 	github.com/russross/blackfriday/v2 v2.1.0 // indirect
 	github.com/ryanuber/go-glob v1.0.0 // indirect
 	github.com/schollz/jsonstore v1.1.0 // indirect
@@ -160,14 +161,14 @@ require (
 	go.opentelemetry.io/otel v1.39.0 // indirect
 	go.opentelemetry.io/otel/metric v1.39.0 // indirect
 	go.opentelemetry.io/otel/trace v1.39.0 // indirect
-	go.yaml.in/yaml/v2 v2.4.2 // indirect
-	golang.org/x/mod v0.32.0 // indirect
+	go.yaml.in/yaml/v2 v2.4.3 // indirect
+	golang.org/x/mod v0.33.0 // indirect
 	golang.org/x/oauth2 v0.34.0 // indirect
 	golang.org/x/sys v0.41.0 // indirect
 	golang.org/x/term v0.40.0 // indirect
 	golang.org/x/text v0.34.0 // indirect
 	golang.org/x/time v0.14.0 // indirect
-	golang.org/x/tools v0.41.0 // indirect
+	golang.org/x/tools v0.42.0 // indirect
 	google.golang.org/genproto v0.0.0-20260128011058-8636f8732409 // indirect
 	google.golang.org/genproto/googleapis/api v0.0.0-20260128011058-8636f8732409 // indirect
 	google.golang.org/genproto/googleapis/rpc v0.0.0-20260128011058-8636f8732409 // indirect

+ 20 - 18
go.sum

@@ -14,8 +14,10 @@ cloud.google.com/go/longrunning v0.8.0 h1:LiKK77J3bx5gDLi4SMViHixjD2ohlkwBi+mKA7
 cloud.google.com/go/longrunning v0.8.0/go.mod h1:UmErU2Onzi+fKDg2gR7dusz11Pe26aknR4kHmJJqIfk=
 cloud.google.com/go/security v1.19.2 h1:cF3FkCRRbRC1oXuaGZFl3qU2sdu2gP3iOAHKzL5y04Y=
 cloud.google.com/go/security v1.19.2/go.mod h1:KXmf64mnOsLVKe8mk/bZpU1Rsvxqc0Ej0A6tgCeN93w=
-dario.cat/mergo v1.0.1 h1:Ra4+bf83h2ztPIQYNP99R6m+Y7KfnARDfID+a+vLl4s=
-dario.cat/mergo v1.0.1/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk=
+dario.cat/mergo v1.0.2 h1:85+piFYR1tMbRrLcDwR18y4UKJ3aH1Tbzi24VRW1TK8=
+dario.cat/mergo v1.0.2/go.mod h1:E/hbnu0NxMFBjpMIE34DRGLWqDy0g5FuKDhCb31ngxA=
+filippo.io/bigmod v0.1.0 h1:UNzDk7y9ADKST+axd9skUpBQeW7fG2KrTZyOE4uGQy8=
+filippo.io/bigmod v0.1.0/go.mod h1:OjOXDNlClLblvXdwgFFOQFJEocLhhtai8vGLy0JCZlI=
 filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
 filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
 github.com/AndreasBriese/bbloom v0.0.0-20190825152654-46b345b51c96 h1:cTp8I5+VIoKjsnZuH8vjyaysT/ses3EvZeaV/1UkF2M=
@@ -289,8 +291,8 @@ github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D
 github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d h1:5PJl274Y63IEHC+7izoQE9x6ikvDFZS2mDVS3drnohI=
 github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE=
 github.com/miekg/pkcs11 v1.0.3-0.20190429190417-a667d056470f/go.mod h1:XsNlhZGX73bx86s2hdc/FuaLm2CPZJemRLMA+WTFxgs=
-github.com/miekg/pkcs11 v1.1.1 h1:Ugu9pdy6vAYku5DEpVWVFPYnzV+bxB+iRdbuFSu7TvU=
-github.com/miekg/pkcs11 v1.1.1/go.mod h1:XsNlhZGX73bx86s2hdc/FuaLm2CPZJemRLMA+WTFxgs=
+github.com/miekg/pkcs11 v1.1.2 h1:/VxmeAX5qU6Q3EwafypogwWbYryHFmF2RpkJmw3m4MQ=
+github.com/miekg/pkcs11 v1.1.2/go.mod h1:XsNlhZGX73bx86s2hdc/FuaLm2CPZJemRLMA+WTFxgs=
 github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa15WveJJGw=
 github.com/mitchellh/copystructure v1.2.0/go.mod h1:qLl+cE2AmVv+CoeAwDPye/v+N2HKCj9FbZEVFJRxO9s=
 github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
@@ -320,10 +322,10 @@ github.com/prometheus/client_golang v1.23.2 h1:Je96obch5RDVy3FDMndoUsjAhG5Edi49h
 github.com/prometheus/client_golang v1.23.2/go.mod h1:Tb1a6LWHB3/SPIzCoaDXI4I8UHKeFTEQ1YCr+0Gyqmg=
 github.com/prometheus/client_model v0.6.2 h1:oBsgwpGs7iVziMvrGhE53c/GrLUsZdHnqNwqPLxwZyk=
 github.com/prometheus/client_model v0.6.2/go.mod h1:y3m2F6Gdpfy6Ut/GBsUqTWZqCUvMVzSfMLjcu6wAwpE=
-github.com/prometheus/common v0.66.1 h1:h5E0h5/Y8niHc5DlaLlWLArTQI7tMrsfQjHV+d9ZoGs=
-github.com/prometheus/common v0.66.1/go.mod h1:gcaUsgf3KfRSwHY4dIMXLPV0K/Wg1oZ8+SbZk/HH/dA=
-github.com/prometheus/procfs v0.16.1 h1:hZ15bTNuirocR6u0JZ6BAHHmwS1p8B4P6MRqxtzMyRg=
-github.com/prometheus/procfs v0.16.1/go.mod h1:teAbpZRB1iIAJYREa1LsoWUXykVXA1KlTmWl8x/U+Is=
+github.com/prometheus/common v0.67.5 h1:pIgK94WWlQt1WLwAC5j2ynLaBRDiinoAb86HZHTUGI4=
+github.com/prometheus/common v0.67.5/go.mod h1:SjE/0MzDEEAyrdr5Gqc6G+sXI67maCxzaT3A2+HqjUw=
+github.com/prometheus/procfs v0.19.2 h1:zUMhqEW66Ex7OXIiDkll3tl9a1ZdilUOd/F6ZXw4Vws=
+github.com/prometheus/procfs v0.19.2/go.mod h1:M0aotyiemPhBCM0z5w87kL22CxfcH05ZpYlu+b4J7mw=
 github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
 github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ=
 github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc=
@@ -342,8 +344,8 @@ github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5I
 github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
 github.com/sirupsen/logrus v1.9.4 h1:TsZE7l11zFCLZnZ+teH4Umoq5BhEIfIzfRDZ1Uzql2w=
 github.com/sirupsen/logrus v1.9.4/go.mod h1:ftWc9WdOfJ0a92nsE2jF5u5ZwH8Bv2zdeOC42RjbV2g=
-github.com/slackhq/nebula v1.9.7 h1:v5u46efIyYHGdfjFnozQbRRhMdaB9Ma1SSTcUcE2lfE=
-github.com/slackhq/nebula v1.9.7/go.mod h1:1+4q4wd3dDAjO8rKCttSb9JIVbklQhuJiBp5I0lbIsQ=
+github.com/slackhq/nebula v1.10.3 h1:EstYj8ODEcv6T0R9X5BVq1zgWZnyU5gtPzk99QF1PMU=
+github.com/slackhq/nebula v1.10.3/go.mod h1:IL5TUQm4x9IFx2kCKPYm1gP47pwd5b8QGnnBH2RHnvs=
 github.com/smallstep/assert v0.0.0-20200723003110-82e2b9b3b262 h1:unQFBIznI+VYD1/1fApl1A+9VcBk+9dcqGfnePY87LY=
 github.com/smallstep/assert v0.0.0-20200723003110-82e2b9b3b262/go.mod h1:MyOHs9Po2fbM1LHej6sBUT8ozbxmMOFG+E+rx/GSGuc=
 github.com/smallstep/cli-utils v0.12.2 h1:lGzM9PJrH/qawbzMC/s2SvgLdJPKDWKwKzx9doCVO+k=
@@ -421,8 +423,8 @@ go.uber.org/mock v0.6.0 h1:hyF9dfmbgIX5EfOdasqLsWD6xqpNZlXblLB/Dbnwv3Y=
 go.uber.org/mock v0.6.0/go.mod h1:KiVJ4BqZJaMj4svdfmHM0AUx4NJYO8ZNpPnZn1Z+BBU=
 go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
 go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
-go.yaml.in/yaml/v2 v2.4.2 h1:DzmwEr2rDGHl7lsFgAHxmNz/1NlQ7xLIrlN2h5d1eGI=
-go.yaml.in/yaml/v2 v2.4.2/go.mod h1:081UH+NErpNdqlCXm3TtEran0rJZGxAYx9hb/ELlsPU=
+go.yaml.in/yaml/v2 v2.4.3 h1:6gvOSjQoTB3vt1l+CU+tSyi/HOjfOjRLJ4YwYZGwRO0=
+go.yaml.in/yaml/v2 v2.4.3/go.mod h1:zSxWcmIDjOzPXpjlTTbAsKokqkDNAVtZO0WOMiT90s8=
 golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
 golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
 golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
@@ -437,8 +439,8 @@ golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
 golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
 golang.org/x/mod v0.15.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
 golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
-golang.org/x/mod v0.32.0 h1:9F4d3PHLljb6x//jOyokMv3eX+YDeepZSEo3mFJy93c=
-golang.org/x/mod v0.32.0/go.mod h1:SgipZ/3h2Ci89DlEtEXWUk/HteuRin+HHhN+WbNhguU=
+golang.org/x/mod v0.33.0 h1:tHFzIWbBifEmbwtGz65eaWyGiGZatSrT9prnU8DbVL8=
+golang.org/x/mod v0.33.0/go.mod h1:swjeQEj+6r7fODbD2cqrnje9PnziFuw4bmLbBZFrQ5w=
 golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
 golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
 golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
@@ -448,8 +450,8 @@ golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
 golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk=
 golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
 golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM=
-golang.org/x/net v0.49.0 h1:eeHFmOGUTtaaPSGNmjBKpbng9MulQsJURQUAfUwY++o=
-golang.org/x/net v0.49.0/go.mod h1:/ysNB2EvaqvesRkuLAyjI1ycPZlQHM3q01F02UY/MV8=
+golang.org/x/net v0.50.0 h1:ucWh9eiCGyDR3vtzso0WMQinm2Dnt8cFMuQa9K33J60=
+golang.org/x/net v0.50.0/go.mod h1:UgoSli3F/pBgdJBHCTc+tp3gmrU4XswgGRgtnwWTfyM=
 golang.org/x/oauth2 v0.34.0 h1:hqK/t4AKgbqWkdkcAeI8XLmbK+4m4G5YeQRrmiotGlw=
 golang.org/x/oauth2 v0.34.0/go.mod h1:lzm5WQJQwKZ3nwavOZ3IS5Aulzxi68dUSgRHujetwEA=
 golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
@@ -516,8 +518,8 @@ golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc
 golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
 golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58=
 golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk=
-golang.org/x/tools v0.41.0 h1:a9b8iMweWG+S0OBnlU36rzLp20z1Rp10w+IY2czHTQc=
-golang.org/x/tools v0.41.0/go.mod h1:XSY6eDqxVNiYgezAVqqCeihT4j1U2CCsqvH3WhQpnlg=
+golang.org/x/tools v0.42.0 h1:uNgphsn75Tdz5Ji2q36v/nsFSfR/9BRFvqhGBaJGd5k=
+golang.org/x/tools v0.42.0/go.mod h1:Ma6lCIwGZvHK6XtgbswSoWroEkhugApmsXyrUmBhfr0=
 golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
 gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk=
 gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E=