Skip to content

Commit

Permalink
[fix] Fixed 0010 pki migration when cert serial_number is None
Browse files Browse the repository at this point in the history
  • Loading branch information
nemesifier committed Aug 10, 2021
1 parent f4ec817 commit cd55ea4
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Generated by Django 3.1.12 on 2021-07-06 12:22

from uuid import uuid4

import shortuuid
from django.db import migrations, models
from swapper import load_model
Expand Down Expand Up @@ -52,6 +54,10 @@ def make_cert_common_name_unique(apps, schema_editor):
unique_slug = shortuuid.ShortUUID().random(length=8)
common_name = f'{common_name}-{unique_slug}'
dupe_cn_cert.common_name = common_name
# in some older versions `serial_number` can be None
# in this case we'll assign a serial number while renewing
if dupe_cn_cert.serial_number is None:
dupe_cn_cert.serial_number = uuid4().int
dupe_cn_cert.renew()


Expand Down

0 comments on commit cd55ea4

Please sign in to comment.