mirror of
https://github.com/gravitl/netmaker.git
synced 2025-09-06 05:04:27 +08:00
review comments addressed
Signed-off-by: Matthew R. Kasun <mkasun@nusak.ca>
This commit is contained in:
parent
b47c72ead2
commit
adfa5236f8
3 changed files with 8 additions and 7 deletions
|
@ -37,7 +37,6 @@ services:
|
|||
MQ_HOST: "mq"
|
||||
HOST_NETWORK: "off"
|
||||
MANAGE_IPTABLES: "on"
|
||||
PORT_FORWARD_SERVICES: ""
|
||||
VERBOSITY: "1"
|
||||
ports:
|
||||
- "51821-51830:51821-51830/udp"
|
||||
|
|
|
@ -50,6 +50,7 @@ func Register(cfg *config.ClientConfig, key string) error {
|
|||
return JoinNetwork(cfg, key, false)
|
||||
}
|
||||
|
||||
// RegisterWithServer calls the register endpoint with privatekey and commonname - api returns ca and client certificate
|
||||
func RegisterWithServer(private *ed25519.PrivateKey, cfg *config.ClientConfig) error {
|
||||
data := config.RegisterRequest{
|
||||
Key: *private,
|
||||
|
|
13
tls/tls.go
13
tls/tls.go
|
@ -17,10 +17,11 @@ import (
|
|||
"golang.zx2c4.com/wireguard/wgctrl/wgtypes"
|
||||
)
|
||||
|
||||
// certificate validity in days
|
||||
// CERTTIFICAT_VALIDITY duration of certificate validity in days
|
||||
const CERTIFICATE_VALIDITY = 365
|
||||
|
||||
type (
|
||||
// Key is the struct for an edwards representation point
|
||||
Key struct {
|
||||
point *edwards25519.Point
|
||||
}
|
||||
|
@ -34,7 +35,7 @@ func NewKey() *Key {
|
|||
return &Key{(&edwards25519.Point{}).ScalarBaseMult(s)}
|
||||
}
|
||||
|
||||
// Ed25519PrivateKey returns the private key in Edwards form used for EdDSA.
|
||||
// Key.Ed25519PrivateKey returns the private key in Edwards form used for EdDSA.
|
||||
func (n *Key) Ed25519PrivateKey() (ed25519.PrivateKey, error) {
|
||||
if n.point == nil {
|
||||
return ed25519.PrivateKey{}, errors.New("nil point")
|
||||
|
@ -45,7 +46,7 @@ func (n *Key) Ed25519PrivateKey() (ed25519.PrivateKey, error) {
|
|||
return ed25519.NewKeyFromSeed(n.point.Bytes()), nil
|
||||
}
|
||||
|
||||
// Curve25519PrivateKey returns the private key in Montogomery form used for ECDH.
|
||||
// Key.Curve25519PrivateKey returns the private key in Montogomery form used for ECDH.
|
||||
func (n *Key) Curve25519PrivateKey() (wgtypes.Key, error) {
|
||||
if n.point == nil {
|
||||
return wgtypes.Key{}, errors.New("nil point")
|
||||
|
@ -56,7 +57,7 @@ func (n *Key) Curve25519PrivateKey() (wgtypes.Key, error) {
|
|||
return wgtypes.ParseKey(base64.StdEncoding.EncodeToString(n.point.BytesMontgomery()))
|
||||
}
|
||||
|
||||
// Save : saves the private key to path.
|
||||
// Key.Save : saves the private key to path.
|
||||
func (n *Key) Save(path string) error {
|
||||
f, err := os.Create(path)
|
||||
if err != nil {
|
||||
|
@ -67,7 +68,7 @@ func (n *Key) Save(path string) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// Reads the private key from path.
|
||||
// ReadFrom reads a private key from path.
|
||||
func ReadFrom(path string) (*Key, error) {
|
||||
key, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
|
@ -80,7 +81,7 @@ func ReadFrom(path string) (*Key, error) {
|
|||
return &Key{point}, nil
|
||||
}
|
||||
|
||||
// NewName creates a new pkix.Name
|
||||
// NewName creates a new pkix.Name with common name, country, and organization
|
||||
func NewName(commonName, country, org string) pkix.Name {
|
||||
res := NewCName(commonName)
|
||||
res.Country = []string{country}
|
||||
|
|
Loading…
Add table
Reference in a new issue