Skip to content

Commit b794bd6

Browse files
committed
Fixes #14499: Relax requirements for encryption/auth algorithms on IKE & IPSec proposals
1 parent 96878cf commit b794bd6

File tree

4 files changed

+24
-7
lines changed

4 files changed

+24
-7
lines changed

docs/models/vpn/ikeproposal.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ The protocol employed for data encryption. Options include DES, 3DES, and variou
2828

2929
### Authentication Algorithm
3030

31-
The mechanism employed to ensure data integrity. Options include MD5 and SHA HMAC implementations.
31+
The mechanism employed to ensure data integrity. Options include MD5 and SHA HMAC implementations. Specifying an authentication algorithm is optional, as some encryption algorithms (e.g. AES-GCM) provide authentication natively.
3232

3333
### Group
3434

docs/models/vpn/ipsecproposal.md

+6
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,16 @@ The unique user-assigned name for the proposal.
1212

1313
The protocol employed for data encryption. Options include DES, 3DES, and various flavors of AES.
1414

15+
!!! note
16+
If an encryption algorithm is not specified, an authentication algorithm must be specified.
17+
1518
### Authentication Algorithm
1619

1720
The mechanism employed to ensure data integrity. Options include MD5 and SHA HMAC implementations.
1821

22+
!!! note
23+
If an authentication algorithm is not specified, an encryption algorithm must be specified.
24+
1925
### SA Lifetime (Seconds)
2026

2127
The maximum amount of time for which the security association (SA) may be active, in seconds.

netbox/vpn/migrations/0001_initial.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class Migration(migrations.Migration):
2929
('name', models.CharField(max_length=100, unique=True)),
3030
('authentication_method', models.CharField()),
3131
('encryption_algorithm', models.CharField()),
32-
('authentication_algorithm', models.CharField()),
32+
('authentication_algorithm', models.CharField(blank=True)),
3333
('group', models.PositiveSmallIntegerField()),
3434
('sa_lifetime', models.PositiveIntegerField(blank=True, null=True)),
3535
('tags', taggit.managers.TaggableManager(through='extras.TaggedItem', to='extras.Tag')),
@@ -82,8 +82,8 @@ class Migration(migrations.Migration):
8282
('description', models.CharField(blank=True, max_length=200)),
8383
('comments', models.TextField(blank=True)),
8484
('name', models.CharField(max_length=100, unique=True)),
85-
('encryption_algorithm', models.CharField()),
86-
('authentication_algorithm', models.CharField()),
85+
('encryption_algorithm', models.CharField(blank=True)),
86+
('authentication_algorithm', models.CharField(blank=True)),
8787
('sa_lifetime_seconds', models.PositiveIntegerField(blank=True, null=True)),
8888
('sa_lifetime_data', models.PositiveIntegerField(blank=True, null=True)),
8989
('tags', taggit.managers.TaggableManager(through='extras.TaggedItem', to='extras.Tag')),

netbox/vpn/models/crypto.py

+14-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from django.core.exceptions import ValidationError
12
from django.db import models
23
from django.urls import reverse
34
from django.utils.translation import gettext_lazy as _
@@ -34,7 +35,8 @@ class IKEProposal(PrimaryModel):
3435
)
3536
authentication_algorithm = models.CharField(
3637
verbose_name=_('authentication algorithm'),
37-
choices=AuthenticationAlgorithmChoices
38+
choices=AuthenticationAlgorithmChoices,
39+
blank=True
3840
)
3941
group = models.PositiveSmallIntegerField(
4042
verbose_name=_('group'),
@@ -120,11 +122,13 @@ class IPSecProposal(PrimaryModel):
120122
)
121123
encryption_algorithm = models.CharField(
122124
verbose_name=_('encryption'),
123-
choices=EncryptionAlgorithmChoices
125+
choices=EncryptionAlgorithmChoices,
126+
blank=True
124127
)
125128
authentication_algorithm = models.CharField(
126129
verbose_name=_('authentication'),
127-
choices=AuthenticationAlgorithmChoices
130+
choices=AuthenticationAlgorithmChoices,
131+
blank=True
128132
)
129133
sa_lifetime_seconds = models.PositiveIntegerField(
130134
verbose_name=_('SA lifetime (seconds)'),
@@ -154,6 +158,13 @@ def __str__(self):
154158
def get_absolute_url(self):
155159
return reverse('vpn:ipsecproposal', args=[self.pk])
156160

161+
def clean(self):
162+
super().clean()
163+
164+
# Encryption and/or authentication algorithm must be defined
165+
if not self.encryption_algorithm and not self.authentication_algorithm:
166+
raise ValidationError(_("Encryption and/or authentication algorithm must be defined"))
167+
157168

158169
class IPSecPolicy(PrimaryModel):
159170
name = models.CharField(

0 commit comments

Comments
 (0)