Skip to content

Commit c3c4287

Browse files
committed
Support ECDSA P-256 public keys in Nebula token validation
1 parent 26248e8 commit c3c4287

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

authority/provisioner/nebula.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package provisioner
22

33
import (
44
"context"
5+
"crypto/ecdh"
56
"crypto/ed25519"
67
"crypto/x509"
78
"encoding/base64"
@@ -338,9 +339,15 @@ func (p *Nebula) authorizeToken(token string, audiences []string) (*nebula.Nebul
338339
}
339340

340341
var pub interface{}
341-
if c.Details.IsCA {
342+
switch {
343+
case c.Details.Curve == nebula.Curve_P256:
344+
// When Nebula is used with ECDSA P-256 keys, both CAs and clients use the same type.
345+
if pub, err = ecdh.P256().NewPublicKey(c.Details.PublicKey); err != nil {
346+
return nil, nil, errs.UnauthorizedErr(err, errs.WithMessage("failed to parse nebula public key"))
347+
}
348+
case c.Details.IsCA:
342349
pub = ed25519.PublicKey(c.Details.PublicKey)
343-
} else {
350+
default:
344351
pub = x25519.PublicKey(c.Details.PublicKey)
345352
}
346353

0 commit comments

Comments
 (0)