mirror of
https://github.com/gravitl/netmaker.git
synced 2025-09-10 15:14:22 +08:00
use cert request public key
This commit is contained in:
parent
de7ca68c23
commit
1adee64e21
1 changed files with 9 additions and 11 deletions
20
tls/tls.go
20
tls/tls.go
|
@ -148,18 +148,16 @@ func SelfSignedCA(key ed25519.PrivateKey, req *x509.CertificateRequest, days int
|
||||||
// issues a new certificate from a parent certificate authority
|
// issues a new certificate from a parent certificate authority
|
||||||
func NewEndEntityCert(key ed25519.PrivateKey, req *x509.CertificateRequest, parent *x509.Certificate, days int) (*x509.Certificate, error) {
|
func NewEndEntityCert(key ed25519.PrivateKey, req *x509.CertificateRequest, parent *x509.Certificate, days int) (*x509.Certificate, error) {
|
||||||
template := &x509.Certificate{
|
template := &x509.Certificate{
|
||||||
Version: req.Version,
|
Version: req.Version,
|
||||||
NotBefore: time.Now(),
|
NotBefore: time.Now(),
|
||||||
NotAfter: time.Now().Add(duration(days)),
|
NotAfter: time.Now().Add(duration(days)),
|
||||||
SerialNumber: serialNumber(),
|
SerialNumber: serialNumber(),
|
||||||
SignatureAlgorithm: req.SignatureAlgorithm,
|
Subject: req.Subject,
|
||||||
PublicKeyAlgorithm: req.PublicKeyAlgorithm,
|
Issuer: parent.Subject,
|
||||||
PublicKey: key.Public(),
|
KeyUsage: x509.KeyUsageDigitalSignature,
|
||||||
Subject: req.Subject,
|
BasicConstraintsValid: true,
|
||||||
SubjectKeyId: req.RawSubject,
|
|
||||||
Issuer: parent.Subject,
|
|
||||||
}
|
}
|
||||||
rootCa, err := x509.CreateCertificate(rand.Reader, template, parent, key.Public(), key)
|
rootCa, err := x509.CreateCertificate(rand.Reader, template, parent, req.PublicKey, key)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue