# Generated by Django 3.0.6 on 2020-05-29 12:54

import pki.models

import django.core.validators
import django.db.models.deletion
from django.db import migrations, models


class Migration(migrations.Migration):

    initial = True

    dependencies = []

    operations = [
        migrations.CreateModel(
            name="ExtendedKeyUsage",
            fields=[
                ("id", models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
                ("name", models.CharField(max_length=64, unique=True)),
            ],
        ),
        migrations.CreateModel(
            name="KeyUsage",
            fields=[
                ("id", models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
                ("name", models.CharField(max_length=64, unique=True)),
            ],
        ),
        migrations.CreateModel(
            name="PkiChangelog",
            fields=[
                ("id", models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
                ("model_id", models.IntegerField()),
                ("object_id", models.IntegerField()),
                ("action_time", models.DateTimeField(auto_now=True)),
                ("action", models.CharField(max_length=64)),
                ("user", models.CharField(max_length=20)),
                ("changes", models.TextField()),
            ],
            options={"db_table": "pki_changelog", "ordering": ["-action_time"],},
        ),
        migrations.CreateModel(
            name="X509Extension",
            fields=[
                ("id", models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
                (
                    "name",
                    models.CharField(
                        max_length=255,
                        unique=True,
                        validators=[
                            django.core.validators.RegexValidator(
                                "[a-zA-Z0-9-_\\.]+", message="Name may only contain characters in range a-Z0-9_-."
                            )
                        ],
                    ),
                ),
                ("description", models.CharField(max_length=255)),
                ("created", models.DateTimeField(auto_now_add=True)),
                (
                    "basic_constraints",
                    models.CharField(
                        choices=[
                            ("CA:TRUE", "Root or Intermediate CA (CA:TRUE)"),
                            ("CA:TRUE, pathlen:0", "Edge CA (CA:TRUE, pathlen:0)"),
                            ("CA:FALSE", "Enduser Certificate (CA:FALSE)"),
                        ],
                        max_length=255,
                        verbose_name="basicConstraints",
                    ),
                ),
                (
                    "basic_constraints_critical",
                    models.BooleanField(default=True, verbose_name="Make basicConstraints critical"),
                ),
                ("key_usage_critical", models.BooleanField(verbose_name="Make keyUsage critical")),
                ("extended_key_usage_critical", models.BooleanField(verbose_name="Make extendedKeyUsage critical")),
                (
                    "subject_key_identifier",
                    models.CharField(
                        choices=[("hash", "hash")], default="hash", max_length=255, verbose_name="subjectKeyIdentifier"
                    ),
                ),
                (
                    "authority_key_identifier",
                    models.CharField(
                        choices=[("keyid:always,issuer:always", "keyid: always, issuer: always")],
                        default="keyid:always,issuer:always",
                        max_length=255,
                        verbose_name="authorityKeyIdentifier",
                    ),
                ),
                (
                    "crl_distribution_point",
                    models.BooleanField(
                        help_text="All objects using this x509 extension will require a CRLDistributionPoint",
                        verbose_name="Require CRL Distribution Point",
                    ),
                ),
                (
                    "extended_key_usage",
                    models.ManyToManyField(
                        blank=True,
                        help_text="serverAuth - SSL/TLS Web Server Authentication<br />                     clientAuth - SSL/TLS Web Client Authentication.<br />                     codeSigning - Code signing<br />                     emailProtection - E-mail Protection (S/MIME)<br />                     timeStamping - Trusted Timestamping<br />                     msCodeInd - Microsoft Individual Code Signing (authenticode)<br />                     msCodeCom - Microsoft Commercial Code Signing (authenticode)<br />                     msCTLSign - Microsoft Trust List Signing<br />                     msSGC - Microsoft Server Gated Crypto<br />                     msEFS - Microsoft Encrypted File System<br />                     nsSGC - Netscape Server Gated Crypto<br />",
                        null=True,
                        to="pki.ExtendedKeyUsage",
                        verbose_name="extendedKeyUsage",
                    ),
                ),
                (
                    "key_usage",
                    models.ManyToManyField(
                        help_text="Usual values:<br />                    CA: keyCertSign, cRLsign<br />                    Cert: digitalSignature, nonRedupiation, keyEncipherment<br />",
                        to="pki.KeyUsage",
                        verbose_name="keyUsage",
                    ),
                ),
            ],
            options={"db_table": "pki_x509extension",},
        ),
        migrations.CreateModel(
            name="CertificateAuthority",
            fields=[
                ("id", models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
                ("description", models.CharField(max_length=255)),
                (
                    "country",
                    models.CharField(
                        choices=[
                            ("AD", "AD"),
                            ("AE", "AE"),
                            ("AF", "AF"),
                            ("AG", "AG"),
                            ("AI", "AI"),
                            ("AL", "AL"),
                            ("AM", "AM"),
                            ("AN", "AN"),
                            ("AO", "AO"),
                            ("AQ", "AQ"),
                            ("AR", "AR"),
                            ("AS", "AS"),
                            ("AT", "AT"),
                            ("AU", "AU"),
                            ("AW", "AW"),
                            ("AZ", "AZ"),
                            ("BA", "BA"),
                            ("BB", "BB"),
                            ("BD", "BD"),
                            ("BE", "BE"),
                            ("BF", "BF"),
                            ("BG", "BG"),
                            ("BH", "BH"),
                            ("BI", "BI"),
                            ("BJ", "BJ"),
                            ("BM", "BM"),
                            ("BN", "BN"),
                            ("BO", "BO"),
                            ("BR", "BR"),
                            ("BS", "BS"),
                            ("BT", "BT"),
                            ("BU", "BU"),
                            ("BV", "BV"),
                            ("BW", "BW"),
                            ("BY", "BY"),
                            ("BZ", "BZ"),
                            ("CA", "CA"),
                            ("CC", "CC"),
                            ("CF", "CF"),
                            ("CG", "CG"),
                            ("CH", "CH"),
                            ("CI", "CI"),
                            ("CK", "CK"),
                            ("CL", "CL"),
                            ("CM", "CM"),
                            ("CN", "CN"),
                            ("CO", "CO"),
                            ("CR", "CR"),
                            ("CS", "CS"),
                            ("CU", "CU"),
                            ("CV", "CV"),
                            ("CX", "CX"),
                            ("CY", "CY"),
                            ("CZ", "CZ"),
                            ("DD", "DD"),
                            ("DE", "DE"),
                            ("DJ", "DJ"),
                            ("DK", "DK"),
                            ("DM", "DM"),
                            ("DO", "DO"),
                            ("DZ", "DZ"),
                            ("EC", "EC"),
                            ("EE", "EE"),
                            ("EG", "EG"),
                            ("EH", "EH"),
                            ("ER", "ER"),
                            ("ES", "ES"),
                            ("ET", "ET"),
                            ("FI", "FI"),
                            ("FJ", "FJ"),
                            ("FK", "FK"),
                            ("FM", "FM"),
                            ("FO", "FO"),
                            ("FR", "FR"),
                            ("FX", "FX"),
                            ("GA", "GA"),
                            ("GB", "GB"),
                            ("GD", "GD"),
                            ("GE", "GE"),
                            ("GF", "GF"),
                            ("GH", "GH"),
                            ("GI", "GI"),
                            ("GL", "GL"),
                            ("GM", "GM"),
                            ("GN", "GN"),
                            ("GP", "GP"),
                            ("GQ", "GQ"),
                            ("GR", "GR"),
                            ("GS", "GS"),
                            ("GT", "GT"),
                            ("GU", "GU"),
                            ("GW", "GW"),
                            ("GY", "GY"),
                            ("HK", "HK"),
                            ("HM", "HM"),
                            ("HN", "HN"),
                            ("HR", "HR"),
                            ("HT", "HT"),
                            ("HU", "HU"),
                            ("ID", "ID"),
                            ("IE", "IE"),
                            ("IL", "IL"),
                            ("IN", "IN"),
                            ("IO", "IO"),
                            ("IQ", "IQ"),
                            ("IR", "IR"),
                            ("IS", "IS"),
                            ("IT", "IT"),
                            ("JM", "JM"),
                            ("JO", "JO"),
                            ("JP", "JP"),
                            ("KE", "KE"),
                            ("KG", "KG"),
                            ("KH", "KH"),
                            ("KI", "KI"),
                            ("KM", "KM"),
                            ("KN", "KN"),
                            ("KP", "KP"),
                            ("KR", "KR"),
                            ("KW", "KW"),
                            ("KY", "KY"),
                            ("KZ", "KZ"),
                            ("LA", "LA"),
                            ("LB", "LB"),
                            ("LC", "LC"),
                            ("LI", "LI"),
                            ("LK", "LK"),
                            ("LR", "LR"),
                            ("LS", "LS"),
                            ("LT", "LT"),
                            ("LU", "LU"),
                            ("LV", "LV"),
                            ("LY", "LY"),
                            ("MA", "MA"),
                            ("MC", "MC"),
                            ("MD", "MD"),
                            ("MG", "MG"),
                            ("MH", "MH"),
                            ("ML", "ML"),
                            ("MM", "MM"),
                            ("MN", "MN"),
                            ("MO", "MO"),
                            ("MP", "MP"),
                            ("MQ", "MQ"),
                            ("MR", "MR"),
                            ("MS", "MS"),
                            ("MT", "MT"),
                            ("MU", "MU"),
                            ("MV", "MV"),
                            ("MW", "MW"),
                            ("MX", "MX"),
                            ("MY", "MY"),
                            ("MZ", "MZ"),
                            ("NA", "NA"),
                            ("NC", "NC"),
                            ("NE", "NE"),
                            ("NF", "NF"),
                            ("NG", "NG"),
                            ("NI", "NI"),
                            ("NL", "NL"),
                            ("NO", "NO"),
                            ("NP", "NP"),
                            ("NR", "NR"),
                            ("NT", "NT"),
                            ("NU", "NU"),
                            ("NZ", "NZ"),
                            ("OM", "OM"),
                            ("PA", "PA"),
                            ("PE", "PE"),
                            ("PF", "PF"),
                            ("PG", "PG"),
                            ("PH", "PH"),
                            ("PK", "PK"),
                            ("PL", "PL"),
                            ("PM", "PM"),
                            ("PN", "PN"),
                            ("PR", "PR"),
                            ("PT", "PT"),
                            ("PW", "PW"),
                            ("PY", "PY"),
                            ("QA", "QA"),
                            ("RE", "RE"),
                            ("RO", "RO"),
                            ("RU", "RU"),
                            ("RW", "RW"),
                            ("SA", "SA"),
                            ("SB", "SB"),
                            ("SC", "SC"),
                            ("SD", "SD"),
                            ("SE", "SE"),
                            ("SG", "SG"),
                            ("SH", "SH"),
                            ("SI", "SI"),
                            ("SJ", "SJ"),
                            ("SK", "SK"),
                            ("SL", "SL"),
                            ("SM", "SM"),
                            ("SN", "SN"),
                            ("SO", "SO"),
                            ("SR", "SR"),
                            ("ST", "ST"),
                            ("SU", "SU"),
                            ("SV", "SV"),
                            ("SY", "SY"),
                            ("SZ", "SZ"),
                            ("TC", "TC"),
                            ("TD", "TD"),
                            ("TF", "TF"),
                            ("TG", "TG"),
                            ("TH", "TH"),
                            ("TJ", "TJ"),
                            ("TK", "TK"),
                            ("TM", "TM"),
                            ("TN", "TN"),
                            ("TO", "TO"),
                            ("TP", "TP"),
                            ("TR", "TR"),
                            ("TT", "TT"),
                            ("TV", "TV"),
                            ("TW", "TW"),
                            ("TZ", "TZ"),
                            ("UA", "UA"),
                            ("UG", "UG"),
                            ("UM", "UM"),
                            ("US", "US"),
                            ("UY", "UY"),
                            ("UZ", "UZ"),
                            ("VA", "VA"),
                            ("VC", "VC"),
                            ("VE", "VE"),
                            ("VG", "VG"),
                            ("VI", "VI"),
                            ("VN", "VN"),
                            ("VU", "VU"),
                            ("WF", "WF"),
                            ("WS", "WS"),
                            ("YD", "YD"),
                            ("YE", "YE"),
                            ("YT", "YT"),
                            ("YU", "YU"),
                            ("ZA", "ZA"),
                            ("ZM", "ZM"),
                            ("ZR", "ZR"),
                            ("ZW", "ZW"),
                            ("ZZ", "ZZ"),
                            ("ZZ", "ZZ"),
                        ],
                        default="RU",
                        max_length=2,
                    ),
                ),
                ("state", models.CharField(default="NOV", max_length=32)),
                ("locality", models.CharField(default="Novosibirsk", max_length=32)),
                ("organization", models.CharField(default="INP", max_length=64)),
                ("OU", models.CharField(blank=True, default="INP", max_length=64, null=True)),
                ("email", models.EmailField(blank=True, default="pisarev@inp.nsk.su", max_length=254, null=True)),
                (
                    "valid_days",
                    models.IntegerField(default=1825, validators=[django.core.validators.MinValueValidator(1)]),
                ),
                (
                    "key_length",
                    models.IntegerField(choices=[(1024, "1024"), (2048, "2048"), (4096, "4096")], default=2048),
                ),
                ("expiry_date", models.DateField(blank=True, null=True)),
                ("created", models.DateTimeField(blank=True, null=True)),
                ("revoked", models.DateTimeField(blank=True, null=True)),
                ("active", models.BooleanField(default=True, help_text="Turn off to revoke this certificate")),
                ("serial", models.CharField(blank=True, max_length=64, null=True)),
                ("ca_chain", models.CharField(blank=True, max_length=200, null=True)),
                ("der_encoded", models.BooleanField(default=False, verbose_name="DER encoding")),
                ("user", models.CharField(blank=True, max_length=64, null=True)),
                (
                    "action",
                    models.CharField(
                        choices=[
                            ("create", "Create certificate"),
                            ("update", "Update description and export options"),
                            ("revoke", "Revoke certificate"),
                            ("renew", "Renew CSR (CN and key are kept)"),
                        ],
                        default="create",
                        help_text="Yellow fields can/have to be modified!",
                        max_length=32,
                    ),
                ),
                (
                    "crl_dpoints",
                    models.CharField(
                        blank=True,
                        help_text="Comma seperated list of URI elements. Example: URI:http://ca.local/ca.crl,...",
                        max_length=255,
                        null=True,
                        validators=[pki.models.validate_crl_dp],
                        verbose_name="CRL Distribution Points",
                    ),
                ),
                ("public", models.BooleanField(default=False, help_text="Public certificate")),
                ("common_name", models.CharField(max_length=64, unique=True)),
                (
                    "name",
                    models.CharField(
                        help_text="Only change the suggestion if you really know what you're doing",
                        max_length=64,
                        unique=True,
                        validators=[
                            django.core.validators.RegexValidator(
                                "[a-zA-Z0-9-_\\.]+", message="Name may only contain characters in range a-Z0-9_-."
                            )
                        ],
                    ),
                ),
                (
                    "passphrase",
                    models.CharField(
                        blank=True,
                        help_text="At least 8 characters. Remeber this passphrase - <font color='red'>                     <strong>IT'S NOT RECOVERABLE</strong></font><br>Will be shown as md5 encrypted string",
                        max_length=255,
                        validators=[django.core.validators.MinLengthValidator(8)],
                    ),
                ),
                (
                    "parent_passphrase",
                    models.CharField(
                        blank=True, help_text="Leave empty if this is a top-level CA", max_length=255, null=True
                    ),
                ),
                (
                    "policy",
                    models.CharField(
                        choices=[("policy_match", "policy_match"), ("policy_anything", "policy_anything")],
                        default="policy_anything",
                        help_text="policy_match: All subject settings must                     match the signing CA<br>                     policy_anything: Nothing has to match the                     signing CA",
                        max_length=50,
                    ),
                ),
                (
                    "extension",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        to="pki.X509Extension",
                        verbose_name="x509 Extension",
                    ),
                ),
                (
                    "parent",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        to="pki.CertificateAuthority",
                    ),
                ),
            ],
            options={
                "verbose_name_plural": "Certificate Authorities",
                "db_table": "pki_certificateauthority",
                "permissions": (("can_download", "Can download"),),
            },
        ),
        migrations.CreateModel(
            name="Certificate",
            fields=[
                ("id", models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
                ("description", models.CharField(max_length=255)),
                (
                    "country",
                    models.CharField(
                        choices=[
                            ("AD", "AD"),
                            ("AE", "AE"),
                            ("AF", "AF"),
                            ("AG", "AG"),
                            ("AI", "AI"),
                            ("AL", "AL"),
                            ("AM", "AM"),
                            ("AN", "AN"),
                            ("AO", "AO"),
                            ("AQ", "AQ"),
                            ("AR", "AR"),
                            ("AS", "AS"),
                            ("AT", "AT"),
                            ("AU", "AU"),
                            ("AW", "AW"),
                            ("AZ", "AZ"),
                            ("BA", "BA"),
                            ("BB", "BB"),
                            ("BD", "BD"),
                            ("BE", "BE"),
                            ("BF", "BF"),
                            ("BG", "BG"),
                            ("BH", "BH"),
                            ("BI", "BI"),
                            ("BJ", "BJ"),
                            ("BM", "BM"),
                            ("BN", "BN"),
                            ("BO", "BO"),
                            ("BR", "BR"),
                            ("BS", "BS"),
                            ("BT", "BT"),
                            ("BU", "BU"),
                            ("BV", "BV"),
                            ("BW", "BW"),
                            ("BY", "BY"),
                            ("BZ", "BZ"),
                            ("CA", "CA"),
                            ("CC", "CC"),
                            ("CF", "CF"),
                            ("CG", "CG"),
                            ("CH", "CH"),
                            ("CI", "CI"),
                            ("CK", "CK"),
                            ("CL", "CL"),
                            ("CM", "CM"),
                            ("CN", "CN"),
                            ("CO", "CO"),
                            ("CR", "CR"),
                            ("CS", "CS"),
                            ("CU", "CU"),
                            ("CV", "CV"),
                            ("CX", "CX"),
                            ("CY", "CY"),
                            ("CZ", "CZ"),
                            ("DD", "DD"),
                            ("DE", "DE"),
                            ("DJ", "DJ"),
                            ("DK", "DK"),
                            ("DM", "DM"),
                            ("DO", "DO"),
                            ("DZ", "DZ"),
                            ("EC", "EC"),
                            ("EE", "EE"),
                            ("EG", "EG"),
                            ("EH", "EH"),
                            ("ER", "ER"),
                            ("ES", "ES"),
                            ("ET", "ET"),
                            ("FI", "FI"),
                            ("FJ", "FJ"),
                            ("FK", "FK"),
                            ("FM", "FM"),
                            ("FO", "FO"),
                            ("FR", "FR"),
                            ("FX", "FX"),
                            ("GA", "GA"),
                            ("GB", "GB"),
                            ("GD", "GD"),
                            ("GE", "GE"),
                            ("GF", "GF"),
                            ("GH", "GH"),
                            ("GI", "GI"),
                            ("GL", "GL"),
                            ("GM", "GM"),
                            ("GN", "GN"),
                            ("GP", "GP"),
                            ("GQ", "GQ"),
                            ("GR", "GR"),
                            ("GS", "GS"),
                            ("GT", "GT"),
                            ("GU", "GU"),
                            ("GW", "GW"),
                            ("GY", "GY"),
                            ("HK", "HK"),
                            ("HM", "HM"),
                            ("HN", "HN"),
                            ("HR", "HR"),
                            ("HT", "HT"),
                            ("HU", "HU"),
                            ("ID", "ID"),
                            ("IE", "IE"),
                            ("IL", "IL"),
                            ("IN", "IN"),
                            ("IO", "IO"),
                            ("IQ", "IQ"),
                            ("IR", "IR"),
                            ("IS", "IS"),
                            ("IT", "IT"),
                            ("JM", "JM"),
                            ("JO", "JO"),
                            ("JP", "JP"),
                            ("KE", "KE"),
                            ("KG", "KG"),
                            ("KH", "KH"),
                            ("KI", "KI"),
                            ("KM", "KM"),
                            ("KN", "KN"),
                            ("KP", "KP"),
                            ("KR", "KR"),
                            ("KW", "KW"),
                            ("KY", "KY"),
                            ("KZ", "KZ"),
                            ("LA", "LA"),
                            ("LB", "LB"),
                            ("LC", "LC"),
                            ("LI", "LI"),
                            ("LK", "LK"),
                            ("LR", "LR"),
                            ("LS", "LS"),
                            ("LT", "LT"),
                            ("LU", "LU"),
                            ("LV", "LV"),
                            ("LY", "LY"),
                            ("MA", "MA"),
                            ("MC", "MC"),
                            ("MD", "MD"),
                            ("MG", "MG"),
                            ("MH", "MH"),
                            ("ML", "ML"),
                            ("MM", "MM"),
                            ("MN", "MN"),
                            ("MO", "MO"),
                            ("MP", "MP"),
                            ("MQ", "MQ"),
                            ("MR", "MR"),
                            ("MS", "MS"),
                            ("MT", "MT"),
                            ("MU", "MU"),
                            ("MV", "MV"),
                            ("MW", "MW"),
                            ("MX", "MX"),
                            ("MY", "MY"),
                            ("MZ", "MZ"),
                            ("NA", "NA"),
                            ("NC", "NC"),
                            ("NE", "NE"),
                            ("NF", "NF"),
                            ("NG", "NG"),
                            ("NI", "NI"),
                            ("NL", "NL"),
                            ("NO", "NO"),
                            ("NP", "NP"),
                            ("NR", "NR"),
                            ("NT", "NT"),
                            ("NU", "NU"),
                            ("NZ", "NZ"),
                            ("OM", "OM"),
                            ("PA", "PA"),
                            ("PE", "PE"),
                            ("PF", "PF"),
                            ("PG", "PG"),
                            ("PH", "PH"),
                            ("PK", "PK"),
                            ("PL", "PL"),
                            ("PM", "PM"),
                            ("PN", "PN"),
                            ("PR", "PR"),
                            ("PT", "PT"),
                            ("PW", "PW"),
                            ("PY", "PY"),
                            ("QA", "QA"),
                            ("RE", "RE"),
                            ("RO", "RO"),
                            ("RU", "RU"),
                            ("RW", "RW"),
                            ("SA", "SA"),
                            ("SB", "SB"),
                            ("SC", "SC"),
                            ("SD", "SD"),
                            ("SE", "SE"),
                            ("SG", "SG"),
                            ("SH", "SH"),
                            ("SI", "SI"),
                            ("SJ", "SJ"),
                            ("SK", "SK"),
                            ("SL", "SL"),
                            ("SM", "SM"),
                            ("SN", "SN"),
                            ("SO", "SO"),
                            ("SR", "SR"),
                            ("ST", "ST"),
                            ("SU", "SU"),
                            ("SV", "SV"),
                            ("SY", "SY"),
                            ("SZ", "SZ"),
                            ("TC", "TC"),
                            ("TD", "TD"),
                            ("TF", "TF"),
                            ("TG", "TG"),
                            ("TH", "TH"),
                            ("TJ", "TJ"),
                            ("TK", "TK"),
                            ("TM", "TM"),
                            ("TN", "TN"),
                            ("TO", "TO"),
                            ("TP", "TP"),
                            ("TR", "TR"),
                            ("TT", "TT"),
                            ("TV", "TV"),
                            ("TW", "TW"),
                            ("TZ", "TZ"),
                            ("UA", "UA"),
                            ("UG", "UG"),
                            ("UM", "UM"),
                            ("US", "US"),
                            ("UY", "UY"),
                            ("UZ", "UZ"),
                            ("VA", "VA"),
                            ("VC", "VC"),
                            ("VE", "VE"),
                            ("VG", "VG"),
                            ("VI", "VI"),
                            ("VN", "VN"),
                            ("VU", "VU"),
                            ("WF", "WF"),
                            ("WS", "WS"),
                            ("YD", "YD"),
                            ("YE", "YE"),
                            ("YT", "YT"),
                            ("YU", "YU"),
                            ("ZA", "ZA"),
                            ("ZM", "ZM"),
                            ("ZR", "ZR"),
                            ("ZW", "ZW"),
                            ("ZZ", "ZZ"),
                            ("ZZ", "ZZ"),
                        ],
                        default="RU",
                        max_length=2,
                    ),
                ),
                ("state", models.CharField(default="NOV", max_length=32)),
                ("locality", models.CharField(default="Novosibirsk", max_length=32)),
                ("organization", models.CharField(default="INP", max_length=64)),
                ("OU", models.CharField(blank=True, default="INP", max_length=64, null=True)),
                ("email", models.EmailField(blank=True, default="pisarev@inp.nsk.su", max_length=254, null=True)),
                (
                    "valid_days",
                    models.IntegerField(default=1825, validators=[django.core.validators.MinValueValidator(1)]),
                ),
                (
                    "key_length",
                    models.IntegerField(choices=[(1024, "1024"), (2048, "2048"), (4096, "4096")], default=2048),
                ),
                ("expiry_date", models.DateField(blank=True, null=True)),
                ("created", models.DateTimeField(blank=True, null=True)),
                ("revoked", models.DateTimeField(blank=True, null=True)),
                ("active", models.BooleanField(default=True, help_text="Turn off to revoke this certificate")),
                ("serial", models.CharField(blank=True, max_length=64, null=True)),
                ("ca_chain", models.CharField(blank=True, max_length=200, null=True)),
                ("der_encoded", models.BooleanField(default=False, verbose_name="DER encoding")),
                ("user", models.CharField(blank=True, max_length=64, null=True)),
                (
                    "action",
                    models.CharField(
                        choices=[
                            ("create", "Create certificate"),
                            ("update", "Update description and export options"),
                            ("revoke", "Revoke certificate"),
                            ("renew", "Renew CSR (CN and key are kept)"),
                        ],
                        default="create",
                        help_text="Yellow fields can/have to be modified!",
                        max_length=32,
                    ),
                ),
                (
                    "crl_dpoints",
                    models.CharField(
                        blank=True,
                        help_text="Comma seperated list of URI elements. Example: URI:http://ca.local/ca.crl,...",
                        max_length=255,
                        null=True,
                        validators=[pki.models.validate_crl_dp],
                        verbose_name="CRL Distribution Points",
                    ),
                ),
                ("public", models.BooleanField(default=False, help_text="Public certificate")),
                ("common_name", models.CharField(max_length=64)),
                (
                    "name",
                    models.CharField(
                        help_text="Only change the suggestion if you really know what you're doing",
                        max_length=64,
                        validators=[
                            django.core.validators.RegexValidator(
                                "[a-zA-Z0-9-_\\.]+", message="Name may only contain characters in range a-Z0-9_-."
                            )
                        ],
                    ),
                ),
                (
                    "passphrase",
                    models.CharField(
                        blank=True, max_length=255, null=True, validators=[django.core.validators.MinLengthValidator(8)]
                    ),
                ),
                ("parent_passphrase", models.CharField(blank=True, max_length=255, null=True)),
                ("pkcs12_encoded", models.BooleanField(default=False, verbose_name="PKCS#12 encoding")),
                (
                    "pkcs12_passphrase",
                    models.CharField(
                        blank=True,
                        max_length=255,
                        null=True,
                        validators=[django.core.validators.MinLengthValidator(8)],
                        verbose_name="PKCS#12 passphrase",
                    ),
                ),
                (
                    "subjaltname",
                    models.CharField(
                        blank=True,
                        help_text="Comma seperated list of alt names. Valid are DNS:www.xyz.com, IP:1.2.3.4 and email:a@b.com in any                     combination. Refer to the official openssl documentation for details",
                        max_length=255,
                        null=True,
                        validators=[pki.models.validate_subject_altname],
                        verbose_name="SubjectAltName",
                    ),
                ),
                (
                    "extension",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        to="pki.X509Extension",
                        verbose_name="x509 Extension",
                    ),
                ),
                (
                    "parent",
                    models.ForeignKey(
                        blank=True,
                        help_text="Leave blank to generate self-signed certificate",
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        to="pki.CertificateAuthority",
                    ),
                ),
            ],
            options={
                "verbose_name_plural": "Certificates",
                "db_table": "pki_certificate",
                "permissions": (("can_download", "Can download"),),
                "unique_together": {("name", "parent"), ("common_name", "parent")},
            },
        ),
    ]
