From f22c89c99832ab37951ebacdf00fb4c3f4f1bfb0 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Sun, 24 May 2020 01:17:52 +0200 Subject: [PATCH] crypto: re-add default self-signed keypair --- .../migrations/0002_create_self_signed_kp.py | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 passbook/crypto/migrations/0002_create_self_signed_kp.py diff --git a/passbook/crypto/migrations/0002_create_self_signed_kp.py b/passbook/crypto/migrations/0002_create_self_signed_kp.py new file mode 100644 index 000000000..645db1dfe --- /dev/null +++ b/passbook/crypto/migrations/0002_create_self_signed_kp.py @@ -0,0 +1,28 @@ +# Generated by Django 3.0.6 on 2020-05-23 23:07 + +from django.db import migrations + + +def create_self_signed(apps, schema_editor): + CertificateKeyPair = apps.get_model("passbook_crypto", "CertificateKeyPair") + db_alias = schema_editor.connection.alias + from passbook.crypto.builder import CertificateBuilder + + builder = CertificateBuilder() + builder.build() + CertificateKeyPair.objects.using(db_alias).create( + name="passbook Self-signed Certificate", + certificate_data=builder.certificate, + key_data=builder.private_key, + ) + + +class Migration(migrations.Migration): + + dependencies = [ + ('passbook_crypto', '0001_initial'), + ] + + operations = [ + migrations.RunPython(create_self_signed) + ]