res_pjsip: allow TLS verification of wildcard cert-bearing servers

Rightly the use of wildcards in certificates is disallowed in accordance
with RFC5922. However, RFC2818 does make some allowances with regards to
their use when using subject alt names with DNS name types.

As such this patch creates a new setting for TLS transports called
'allow_wildcard_certs', which when it and 'verify_server' are both enabled
allows DNS name types, as well as the common name that start with '*.'
to match as a wildcard.

For instance: *.example.com
will match for: foo.example.com

Partial matching is not allowed, e.g. f*.example.com, foo.*.com, etc...
And the starting wildcard only matches for a single level.

For instance: *.example.com
will NOT match for: foo.bar.example.com

The new setting is disabled by default.

ASTERISK-30072 #close

Change-Id: If0be3fdab2e09c2a66bb54824fca406ebaac3da4
This commit is contained in:
Kevin Harwell
2022-06-15 15:41:31 -05:00
parent 8d4a298cd4
commit 2074cf07f6
7 changed files with 218 additions and 2 deletions

View File

@@ -0,0 +1,29 @@
"""allow_wildcard_certs
Revision ID: 58e440314c2a
Revises: 0bee61aa9425
Create Date: 2022-05-12 12:15:55.343743
"""
# revision identifiers, used by Alembic.
revision = '58e440314c2a'
down_revision = 'a06d8f8462d9'
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects.postgresql import ENUM
YESNO_NAME = 'yesno_values'
YESNO_VALUES = ['yes', 'no']
def upgrade():
yesno_values = ENUM(*YESNO_VALUES, name=YESNO_NAME, create_type=False)
op.add_column('ps_transports', sa.Column('allow_wildcard_certs', type_=yesno_values))
def downgrade():
if op.get_context().bind.dialect.name == 'mssql':
op.drop_constraint('ck_ps_transports_allow_wildcard_certs_yesno_values', 'ps_transports')
op.drop_column('ps_transports', 'allow_wildcard_certs')