fix PublicKeys panic
This commit is contained in:
parent
9235e92c0a
commit
0442dc3256
@ -25,6 +25,8 @@ type Yggdrasil struct {
|
|||||||
cache cache.Cache
|
cache cache.Cache
|
||||||
config config.Config
|
config config.Config
|
||||||
prikey *rsa.PrivateKey
|
prikey *rsa.PrivateKey
|
||||||
|
|
||||||
|
pubStr func() string
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewYggdrasil(client *ent.Client, cache cache.Cache, c config.Config, prikey *rsa.PrivateKey) *Yggdrasil {
|
func NewYggdrasil(client *ent.Client, cache cache.Cache, c config.Config, prikey *rsa.PrivateKey) *Yggdrasil {
|
||||||
@ -33,6 +35,10 @@ func NewYggdrasil(client *ent.Client, cache cache.Cache, c config.Config, prikey
|
|||||||
cache: cache,
|
cache: cache,
|
||||||
config: c,
|
config: c,
|
||||||
prikey: prikey,
|
prikey: prikey,
|
||||||
|
pubStr: sync.OnceValue[string](func() string {
|
||||||
|
derBytes := lo.Must(x509.MarshalPKIXPublicKey(&prikey.PublicKey))
|
||||||
|
return base64.StdEncoding.EncodeToString(derBytes)
|
||||||
|
}),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -93,8 +99,7 @@ var mojangPubKeyStr = sync.OnceValue(func() string {
|
|||||||
|
|
||||||
func (y *Yggdrasil) PublicKeys(ctx context.Context) yggdrasil.PublicKeys {
|
func (y *Yggdrasil) PublicKeys(ctx context.Context) yggdrasil.PublicKeys {
|
||||||
mojangPub := mojangPubKeyStr()
|
mojangPub := mojangPubKeyStr()
|
||||||
derBytes := lo.Must(x509.MarshalPKIXPublicKey(y.prikey.PublicKey))
|
myPub := y.pubStr()
|
||||||
myPub := base64.StdEncoding.EncodeToString(derBytes)
|
|
||||||
|
|
||||||
pl := []yggdrasil.PublicKeyList{{PublicKey: mojangPub}, {PublicKey: myPub}}
|
pl := []yggdrasil.PublicKeyList{{PublicKey: mojangPub}, {PublicKey: myPub}}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user