mirror of
https://github.com/caddyserver/caddy.git
synced 2025-11-01 22:32:23 +08:00
caddypki: check intermediate lifetime to actual root cert lifetime (#7272)
This commit is contained in:
@ -124,8 +124,6 @@ func (ca *CA) Provision(ctx caddy.Context, id string, log *zap.Logger) error {
|
|||||||
}
|
}
|
||||||
if ca.IntermediateLifetime == 0 {
|
if ca.IntermediateLifetime == 0 {
|
||||||
ca.IntermediateLifetime = caddy.Duration(defaultIntermediateLifetime)
|
ca.IntermediateLifetime = caddy.Duration(defaultIntermediateLifetime)
|
||||||
} else if time.Duration(ca.IntermediateLifetime) >= defaultRootLifetime {
|
|
||||||
return fmt.Errorf("intermediate certificate lifetime must be less than root certificate lifetime (%s)", defaultRootLifetime)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// load the certs and key that will be used for signing
|
// load the certs and key that will be used for signing
|
||||||
@ -144,6 +142,10 @@ func (ca *CA) Provision(ctx caddy.Context, id string, log *zap.Logger) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
actualRootLifetime := time.Until(rootCert.NotAfter)
|
||||||
|
if time.Duration(ca.IntermediateLifetime) >= actualRootLifetime {
|
||||||
|
return fmt.Errorf("intermediate certificate lifetime must be less than actual root certificate lifetime (%s)", actualRootLifetime)
|
||||||
|
}
|
||||||
if ca.Intermediate != nil {
|
if ca.Intermediate != nil {
|
||||||
interCert, interKey, err = ca.Intermediate.Load()
|
interCert, interKey, err = ca.Intermediate.Load()
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user