Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow configuring default validity for cab_compliant CAs #4977

Merged
merged 1 commit into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions docker/src/lemur.conf.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
import base64
import os.path
import secrets
import string
from typing import Dict, Any, List

from celery.schedules import crontab

import base64

_basedir = os.path.abspath(os.path.dirname(__file__))

# See the Lemur docs (https://lemur.readthedocs.org) for more information on configuration
Expand Down Expand Up @@ -167,6 +164,7 @@ def get_random_secret(length):
# mail configuration
# MAIL_SERVER = 'mail.example.com'

PUBLIC_CA_DEFAULT_VALIDITY_DAYS = 397
PUBLIC_CA_MAX_VALIDITY_DAYS = 397
DEFAULT_VALIDITY_DAYS = 365

Expand Down
15 changes: 14 additions & 1 deletion docs/administration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -238,11 +238,24 @@ Basic Configuration
LEMUR_ENCRYPTION_KEYS = ['1YeftooSbxCiX2zo8m1lXtpvQjy27smZcUUaGmffhMY=', 'LAfQt6yrkLqOK5lwpvQcT4jf2zdeTQJV1uYeh9coT5s=']


.. data:: PUBLIC_CA_DEFAULT_VALIDITY_DAYS
:noindex:

Use this config to set a default validity for certificates issued by CA/Browser compliant authorities.
The authorities with cab_compliant option set to true will use this config. This value defaults to
`PUBLIC_CA_MAX_VALIDITY_DAYS` (see below) if not configured. The example below overrides the default validity
to 365 days.

::

PUBLIC_CA_DEFAULT_VALIDITY_DAYS = 365


.. data:: PUBLIC_CA_MAX_VALIDITY_DAYS
:noindex:

Use this config to override the limit of 397 days of validity for certificates issued by CA/Browser compliant authorities.
The authorities with cab_compliant option set to true will use this config. The example below overrides the default validity
The authorities with cab_compliant option set to true will use this config. The example below overrides the default max validity
of 397 days and sets it to 365 days.

::
Expand Down
6 changes: 3 additions & 3 deletions lemur/authorities/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import json

from flask import current_app
from sqlalchemy.orm import relationship
from sqlalchemy import (
Column,
Integer,
Expand All @@ -22,10 +21,11 @@
Boolean,
)
from sqlalchemy.dialects.postgresql import JSON
from sqlalchemy.orm import relationship

from lemur.database import BaseModel, db
from lemur.plugins.base import plugins
from lemur.models import roles_authorities
from lemur.plugins.base import plugins


class Authority(BaseModel):
Expand Down Expand Up @@ -117,7 +117,7 @@ def max_issuance_days(self):
@property
def default_validity_days(self):
if self.is_cab_compliant:
return current_app.config.get("PUBLIC_CA_MAX_VALIDITY_DAYS", 397)
return current_app.config.get("PUBLIC_CA_DEFAULT_VALIDITY_DAYS", current_app.config.get("PUBLIC_CA_MAX_VALIDITY_DAYS", 397))

return current_app.config.get("DEFAULT_VALIDITY_DAYS", 365) # 1 year default

Expand Down