mirror of
https://github.com/XTLS/Xray-core.git
synced 2025-04-30 01:08:33 +00:00
CertificateObject: Enable auto-reload for cacert & Add buildChain & Fixes (#3607)
This commit is contained in:
parent
a342db3e28
commit
4531a7e228
5 changed files with 163 additions and 125 deletions
|
@ -149,10 +149,6 @@ func Generate(parent *Certificate, opts ...Option) (*Certificate, error) {
|
|||
BasicConstraintsValid: true,
|
||||
}
|
||||
|
||||
for _, opt := range opts {
|
||||
opt(template)
|
||||
}
|
||||
|
||||
parentCert := template
|
||||
if parent != nil {
|
||||
pCert, err := x509.ParseCertificate(parent.Certificate)
|
||||
|
@ -162,6 +158,17 @@ func Generate(parent *Certificate, opts ...Option) (*Certificate, error) {
|
|||
parentCert = pCert
|
||||
}
|
||||
|
||||
if parentCert.NotAfter.Before(template.NotAfter) {
|
||||
template.NotAfter = parentCert.NotAfter
|
||||
}
|
||||
if parentCert.NotBefore.After(template.NotBefore) {
|
||||
template.NotBefore = parentCert.NotBefore
|
||||
}
|
||||
|
||||
for _, opt := range opts {
|
||||
opt(template)
|
||||
}
|
||||
|
||||
derBytes, err := x509.CreateCertificate(rand.Reader, template, parentCert, publicKey(selfKey), parentKey)
|
||||
if err != nil {
|
||||
return nil, errors.New("failed to create certificate").Base(err)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue