{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "Protected local REST, native SCEP or static-unlinked EST enrollment configuration, version1",
  "description": "Optional certificate enrollment configuration, format 1. Select exactly one REST, SCEP or EST protocol. Prepare enrollment database schema 4. Staging, activation and dynamic human signing have separate lifecycle and authority rules.",
  "oneOf": [
    {
      "type": "object",
      "required": [
        "schema_version"
      ],
      "additionalProperties": false,
      "properties": {
        "schema_version": {
          "const": 1
        },
        "enabled": {
          "const": false
        }
      }
    },
    {
      "type": "object",
      "required": [
        "schema_version",
        "enabled",
        "profile",
        "provisioning",
        "database",
        "crypto",
        "certificate_policy",
        "maximum_operations",
        "document_key_fingerprints"
      ],
      "additionalProperties": false,
      "properties": {
        "schema_version": {
          "const": 1
        },
        "enabled": {
          "const": true
        },
        "profile": {
          "oneOf": [
            {
              "$ref": "#/$defs/legacyProfile"
            },
            {
              "$ref": "#/$defs/estProfile"
            }
          ]
        },
        "provisioning": {
          "oneOf": [
            {
              "$ref": "#/$defs/legacyProvisioning"
            },
            {
              "$ref": "#/$defs/estProvisioning"
            }
          ]
        },
        "database": {
          "allOf": [
            {
              "$ref": "database.configuration.schema.json"
            },
            {
              "required": [
                "migration"
              ]
            }
          ]
        },
        "crypto": {
          "oneOf": [
            {
              "type": "object",
              "required": [
                "backend",
                "directory",
                "identity",
                "password_file"
              ],
              "additionalProperties": false,
              "properties": {
                "backend": {
                  "const": "PKCS12"
                },
                "directory": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 4096
                },
                "identity": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 64,
                  "pattern": "^[A-Za-z0-9_-]{1,64}$"
                },
                "password_file": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 4096
                }
              }
            },
            {
              "type": "object",
              "required": [
                "backend",
                "directory",
                "identity",
                "pin_file",
                "module_file",
                "module_sha256",
                "slot",
                "token_label",
                "token_serial"
              ],
              "additionalProperties": false,
              "properties": {
                "backend": {
                  "const": "PKCS11"
                },
                "directory": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 4096
                },
                "identity": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 64,
                  "pattern": "^[A-Za-z0-9_-]{1,64}$"
                },
                "pin_file": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 4096
                },
                "module_file": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 4096
                },
                "module_sha256": {
                  "type": "string",
                  "minLength": 64,
                  "maxLength": 64,
                  "pattern": "^[a-f0-9]{64}$"
                },
                "slot": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 9223372036854775807
                },
                "token_label": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 32,
                  "pattern": "^[ -~]+$"
                },
                "token_serial": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 16,
                  "pattern": "^[ -~]+$"
                }
              }
            }
          ]
        },
        "certificate_policy": {
          "type": "object",
          "required": [
            "roots",
            "crls",
            "maximum_lifetime_seconds",
            "maximum_backdating_seconds",
            "minimum_remaining_seconds",
            "staging_retention_seconds",
            "content_commitment",
            "extended_key_usages",
            "certificate_policies",
            "signature_oids",
            "revocation",
            "maximum_crl_age_seconds"
          ],
          "additionalProperties": false,
          "properties": {
            "roots": {
              "type": "array",
              "items": {
                "$ref": "#/$defs/publicFile"
              },
              "maxItems": 8,
              "minItems": 1,
              "uniqueItems": true
            },
            "crls": {
              "type": "array",
              "items": {
                "$ref": "#/$defs/publicFile"
              },
              "maxItems": 8,
              "minItems": 0,
              "uniqueItems": true
            },
            "maximum_lifetime_seconds": {
              "type": "integer",
              "minimum": 1,
              "maximum": 31622400
            },
            "maximum_backdating_seconds": {
              "type": "integer",
              "minimum": 0,
              "maximum": 604800
            },
            "minimum_remaining_seconds": {
              "type": "integer",
              "minimum": 0,
              "maximum": 31622400
            },
            "staging_retention_seconds": {
              "type": "integer",
              "minimum": 1,
              "maximum": 2592000
            },
            "content_commitment": {
              "type": "boolean"
            },
            "extended_key_usages": {
              "type": "array",
              "items": {
                "type": "string",
                "minLength": 3,
                "maxLength": 128
              },
              "maxItems": 8,
              "minItems": 0,
              "uniqueItems": true
            },
            "certificate_policies": {
              "type": "array",
              "items": {
                "type": "string",
                "minLength": 3,
                "maxLength": 128
              },
              "maxItems": 8,
              "minItems": 0,
              "uniqueItems": true
            },
            "signature_oids": {
              "type": "array",
              "items": {
                "enum": [
                  "1.2.840.113549.1.1.11",
                  "1.2.840.113549.1.1.12",
                  "1.2.840.113549.1.1.13",
                  "1.2.840.10045.4.3.2",
                  "1.2.840.10045.4.3.3",
                  "1.2.840.10045.4.3.4"
                ]
              },
              "maxItems": 8,
              "minItems": 1,
              "uniqueItems": true
            },
            "revocation": {
              "enum": [
                "EXPLICIT_NONE",
                "REQUIRE_OFFLINE_CRLS"
              ]
            },
            "maximum_crl_age_seconds": {
              "type": "integer",
              "minimum": 0,
              "maximum": 604800
            }
          },
          "allOf": [
            {
              "if": {
                "properties": {
                  "revocation": {
                    "const": "EXPLICIT_NONE"
                  }
                }
              },
              "then": {
                "properties": {
                  "crls": {
                    "maxItems": 0
                  },
                  "maximum_crl_age_seconds": {
                    "const": 0
                  }
                }
              },
              "else": {
                "properties": {
                  "crls": {
                    "minItems": 1
                  },
                  "maximum_crl_age_seconds": {
                    "minimum": 1
                  }
                }
              }
            }
          ]
        },
        "maximum_operations": {
          "type": "integer",
          "minimum": 1,
          "maximum": 4096
        },
        "document_key_fingerprints": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 64,
            "maxLength": 64,
            "pattern": "^[a-f0-9]{64}$"
          },
          "maxItems": 256,
          "minItems": 0,
          "uniqueItems": true
        },
        "rest": {
          "type": "object",
          "required": [
            "submit",
            "lookup",
            "request_template",
            "response_mapping",
            "lookup_response_mapping",
            "registered_values",
            "maximum_exchange_ms"
          ],
          "additionalProperties": false,
          "properties": {
            "submit": {
              "type": "object",
              "required": [
                "endpoint",
                "authentication"
              ],
              "additionalProperties": false,
              "properties": {
                "endpoint": {
                  "$ref": "#/$defs/endpoint"
                },
                "authentication": {
                  "$ref": "#/$defs/authentication"
                }
              }
            },
            "lookup": {
              "type": "object",
              "required": [
                "endpoint",
                "authentication",
                "method",
                "append_reference"
              ],
              "additionalProperties": false,
              "properties": {
                "endpoint": {
                  "$ref": "#/$defs/endpoint"
                },
                "authentication": {
                  "$ref": "#/$defs/authentication"
                },
                "method": {
                  "enum": [
                    "GET",
                    "POST"
                  ]
                },
                "append_reference": {
                  "type": "boolean"
                },
                "request_template": {
                  "$ref": "external-pki-rest.request-template.schema.json"
                }
              },
              "allOf": [
                {
                  "if": {
                    "properties": {
                      "method": {
                        "const": "GET"
                      }
                    }
                  },
                  "then": {
                    "properties": {
                      "append_reference": {
                        "const": true
                      }
                    },
                    "not": {
                      "required": [
                        "request_template"
                      ]
                    }
                  },
                  "else": {
                    "required": [
                      "request_template"
                    ]
                  }
                }
              ]
            },
            "request_template": {
              "$ref": "external-pki-rest.request-template.schema.json"
            },
            "response_mapping": {
              "$ref": "external-pki-rest.response-mapping.schema.json"
            },
            "lookup_response_mapping": {
              "$ref": "external-pki-rest.response-mapping.schema.json"
            },
            "registered_values": {
              "type": "object",
              "maxProperties": 66,
              "additionalProperties": false,
              "properties": {
                "subject": {
                  "type": "object"
                },
                "sans": {
                  "type": "array"
                }
              },
              "patternProperties": {
                "^identity\\.[A-Za-z][A-Za-z0-9_]{0,63}$": {
                  "type": "string"
                }
              }
            },
            "maximum_exchange_ms": {
              "type": "integer",
              "minimum": 100,
              "maximum": 30000
            }
          }
        },
        "scep": {
          "type": "object",
          "required": [
            "remote",
            "ca_chain",
            "response_signer",
            "request_encryption",
            "challenge_file",
            "challenge_sha256",
            "protocol_directory",
            "maximum_exchange_ms"
          ],
          "additionalProperties": false,
          "properties": {
            "remote": {
              "type": "object",
              "required": [
                "endpoint",
                "authentication"
              ],
              "additionalProperties": false,
              "properties": {
                "endpoint": {
                  "$ref": "#/$defs/endpoint"
                },
                "authentication": {
                  "oneOf": [
                    {
                      "$ref": "#/$defs/authentication"
                    },
                    {
                      "type": "object",
                      "required": [
                        "type",
                        "not_before",
                        "expires_at"
                      ],
                      "additionalProperties": false,
                      "properties": {
                        "type": {
                          "const": "SCEP_NATIVE"
                        },
                        "not_before": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 4096,
                          "format": "date-time"
                        },
                        "expires_at": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 4096,
                          "format": "date-time"
                        }
                      }
                    }
                  ]
                }
              }
            },
            "ca_chain": {
              "type": "array",
              "minItems": 1,
              "maxItems": 3,
              "uniqueItems": true,
              "items": {
                "$ref": "#/$defs/publicFile"
              }
            },
            "response_signer": {
              "$ref": "#/$defs/publicFile"
            },
            "request_encryption": {
              "$ref": "#/$defs/publicFile"
            },
            "challenge_file": {
              "type": "string",
              "minLength": 1,
              "maxLength": 4096
            },
            "challenge_sha256": {
              "type": "string",
              "minLength": 64,
              "maxLength": 64,
              "pattern": "^[a-f0-9]{64}$"
            },
            "protocol_directory": {
              "type": "string",
              "minLength": 1,
              "maxLength": 4096
            },
            "response_content": {
              "enum": [
                "RFC_DATA",
                "XIPKI_6_7_1_TYPED_ENVELOPE"
              ],
              "default": "RFC_DATA"
            },
            "maximum_exchange_ms": {
              "type": "integer",
              "minimum": 100,
              "maximum": 30000
            }
          }
        },
        "est": {
          "type": "object",
          "required": [
            "remote",
            "ca_chain",
            "csr_attributes_profile",
            "identity_pop_linkage",
            "maximum_exchange_ms"
          ],
          "additionalProperties": false,
          "properties": {
            "remote": {
              "type": "object",
              "required": [
                "endpoint",
                "authentication"
              ],
              "additionalProperties": false,
              "properties": {
                "endpoint": {
                  "allOf": [
                    {
                      "$ref": "#/$defs/endpoint"
                    },
                    {
                      "properties": {
                        "url": {
                          "type": "string",
                          "maxLength": 2036,
                          "pattern": "^https://[^?#%]+/$"
                        }
                      }
                    }
                  ]
                },
                "authentication": {
                  "$ref": "#/$defs/estAuthentication"
                }
              },
              "allOf": [
                {
                  "if": {
                    "properties": {
                      "authentication": {
                        "properties": {
                          "type": {
                            "const": "MTLS"
                          }
                        }
                      }
                    }
                  },
                  "then": {
                    "properties": {
                      "endpoint": {
                        "required": [
                          "client_identity"
                        ]
                      }
                    }
                  }
                }
              ]
            },
            "ca_chain": {
              "type": "array",
              "minItems": 1,
              "maxItems": 3,
              "uniqueItems": true,
              "items": {
                "$ref": "#/$defs/publicFile"
              }
            },
            "csr_attributes_profile": {
              "enum": [
                "RFC9908",
                "XIPKI_6_7_1_LEGACY_RSA_HINTS"
              ]
            },
            "identity_pop_linkage": {
              "const": "UNLINKED",
              "description": "Required linkage modes are unsupported and reject before key work; no invented tls-unique/exporter."
            },
            "maximum_exchange_ms": {
              "type": "integer",
              "minimum": 100,
              "maximum": 30000
            }
          }
        }
      },
      "allOf": [
        {
          "oneOf": [
            {
              "required": [
                "rest"
              ],
              "not": {
                "anyOf": [
                  {
                    "required": [
                      "scep"
                    ]
                  },
                  {
                    "required": [
                      "est"
                    ]
                  }
                ]
              }
            },
            {
              "required": [
                "scep"
              ],
              "not": {
                "anyOf": [
                  {
                    "required": [
                      "rest"
                    ]
                  },
                  {
                    "required": [
                      "est"
                    ]
                  }
                ]
              }
            },
            {
              "required": [
                "est"
              ],
              "not": {
                "anyOf": [
                  {
                    "required": [
                      "rest"
                    ]
                  },
                  {
                    "required": [
                      "scep"
                    ]
                  }
                ]
              }
            }
          ]
        },
        {
          "if": {
            "required": [
              "est"
            ]
          },
          "then": {
            "properties": {
              "profile": {
                "$ref": "#/$defs/estProfile"
              },
              "provisioning": {
                "$ref": "#/$defs/estProvisioning"
              }
            }
          },
          "else": {
            "properties": {
              "profile": {
                "$ref": "#/$defs/legacyProfile"
              },
              "provisioning": {
                "$ref": "#/$defs/legacyProvisioning"
              }
            }
          }
        }
      ]
    }
  ],
  "$defs": {
    "publicFile": {
      "type": "object",
      "required": [
        "file",
        "sha256"
      ],
      "additionalProperties": false,
      "properties": {
        "file": {
          "type": "string",
          "minLength": 1,
          "maxLength": 4096
        },
        "sha256": {
          "type": "string",
          "minLength": 64,
          "maxLength": 64,
          "pattern": "^[a-f0-9]{64}$"
        }
      }
    },
    "clientIdentity": {
      "type": "object",
      "required": [
        "file",
        "password_file",
        "alias",
        "certificate_sha256",
        "public_key_fingerprint"
      ],
      "additionalProperties": false,
      "properties": {
        "file": {
          "type": "string",
          "minLength": 1,
          "maxLength": 4096
        },
        "password_file": {
          "type": "string",
          "minLength": 1,
          "maxLength": 4096
        },
        "alias": {
          "type": "string",
          "minLength": 1,
          "maxLength": 128,
          "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"
        },
        "certificate_sha256": {
          "type": "string",
          "minLength": 64,
          "maxLength": 64,
          "pattern": "^[a-f0-9]{64}$"
        },
        "public_key_fingerprint": {
          "type": "string",
          "minLength": 64,
          "maxLength": 64,
          "pattern": "^[a-f0-9]{64}$"
        }
      }
    },
    "endpoint": {
      "type": "object",
      "required": [
        "url",
        "connect_address",
        "trust_roots"
      ],
      "additionalProperties": false,
      "properties": {
        "url": {
          "type": "string",
          "minLength": 1,
          "maxLength": 2048,
          "pattern": "^https://",
          "format": "uri"
        },
        "connect_address": {
          "type": "string",
          "minLength": 1,
          "maxLength": 64
        },
        "trust_roots": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/publicFile"
          },
          "maxItems": 8,
          "minItems": 1,
          "uniqueItems": true
        },
        "client_identity": {
          "$ref": "#/$defs/clientIdentity"
        }
      }
    },
    "authentication": {
      "oneOf": [
        {
          "type": "object",
          "required": [
            "type",
            "not_before",
            "expires_at"
          ],
          "additionalProperties": false,
          "properties": {
            "type": {
              "const": "MTLS"
            },
            "not_before": {
              "type": "string",
              "minLength": 1,
              "maxLength": 4096,
              "format": "date-time"
            },
            "expires_at": {
              "type": "string",
              "minLength": 1,
              "maxLength": 4096,
              "format": "date-time"
            }
          }
        },
        {
          "type": "object",
          "required": [
            "type",
            "not_before",
            "expires_at",
            "username",
            "secret_file"
          ],
          "additionalProperties": false,
          "properties": {
            "type": {
              "const": "BASIC"
            },
            "not_before": {
              "type": "string",
              "minLength": 1,
              "maxLength": 4096,
              "format": "date-time"
            },
            "expires_at": {
              "type": "string",
              "minLength": 1,
              "maxLength": 4096,
              "format": "date-time"
            },
            "username": {
              "type": "string",
              "minLength": 1,
              "maxLength": 128
            },
            "secret_file": {
              "type": "string",
              "minLength": 1,
              "maxLength": 4096
            }
          }
        },
        {
          "type": "object",
          "required": [
            "type",
            "not_before",
            "expires_at",
            "header",
            "secret_file"
          ],
          "additionalProperties": false,
          "properties": {
            "type": {
              "const": "API_KEY"
            },
            "not_before": {
              "type": "string",
              "minLength": 1,
              "maxLength": 4096,
              "format": "date-time"
            },
            "expires_at": {
              "type": "string",
              "minLength": 1,
              "maxLength": 4096,
              "format": "date-time"
            },
            "header": {
              "type": "string",
              "minLength": 3,
              "maxLength": 63,
              "pattern": "^X-[A-Za-z0-9-]{1,61}$"
            },
            "secret_file": {
              "type": "string",
              "minLength": 1,
              "maxLength": 4096
            }
          }
        },
        {
          "type": "object",
          "required": [
            "type",
            "not_before",
            "expires_at",
            "secret_file"
          ],
          "additionalProperties": false,
          "properties": {
            "type": {
              "const": "BEARER"
            },
            "not_before": {
              "type": "string",
              "minLength": 1,
              "maxLength": 4096,
              "format": "date-time"
            },
            "expires_at": {
              "type": "string",
              "minLength": 1,
              "maxLength": 4096,
              "format": "date-time"
            },
            "secret_file": {
              "type": "string",
              "minLength": 1,
              "maxLength": 4096
            }
          }
        },
        {
          "type": "object",
          "required": [
            "type",
            "not_before",
            "expires_at",
            "token_endpoint",
            "client_id",
            "secret_file",
            "scopes",
            "parameters"
          ],
          "additionalProperties": false,
          "properties": {
            "type": {
              "const": "OAUTH2_CLIENT_CREDENTIALS"
            },
            "not_before": {
              "type": "string",
              "minLength": 1,
              "maxLength": 4096,
              "format": "date-time"
            },
            "expires_at": {
              "type": "string",
              "minLength": 1,
              "maxLength": 4096,
              "format": "date-time"
            },
            "token_endpoint": {
              "$ref": "#/$defs/endpoint"
            },
            "client_id": {
              "type": "string",
              "minLength": 1,
              "maxLength": 256
            },
            "secret_file": {
              "type": "string",
              "minLength": 1,
              "maxLength": 4096
            },
            "scopes": {
              "type": "array",
              "items": {
                "type": "string",
                "minLength": 1,
                "maxLength": 64,
                "pattern": "^[\\x21\\x23-\\x5b\\x5d-\\x7e]+$"
              },
              "maxItems": 8,
              "minItems": 1,
              "uniqueItems": true
            },
            "parameters": {
              "type": "object",
              "required": [],
              "additionalProperties": false,
              "properties": {
                "audience": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 512
                },
                "resource": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 512
                }
              }
            }
          }
        }
      ]
    },
    "legacyProfile": {
      "type": "object",
      "required": [
        "provider",
        "profile",
        "correlation",
        "lookup_contract"
      ],
      "additionalProperties": false,
      "properties": {
        "provider": {
          "type": "string",
          "minLength": 1,
          "maxLength": 128,
          "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"
        },
        "profile": {
          "type": "string",
          "minLength": 1,
          "maxLength": 128,
          "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"
        },
        "correlation": {
          "enum": [
            "ISSUER_ORDER_ID",
            "CLIENT_OPERATION_ID"
          ]
        },
        "lookup_contract": {
          "const": "REGISTERED_READ_ONLY"
        }
      }
    },
    "legacyProvisioning": {
      "type": "object",
      "required": [
        "requester",
        "subject_reference",
        "subject",
        "rsa_bits",
        "authority_seconds",
        "reconciliation_seconds",
        "maximum_polls"
      ],
      "additionalProperties": false,
      "properties": {
        "requester": {
          "type": "string",
          "minLength": 1,
          "maxLength": 128,
          "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"
        },
        "subject_reference": {
          "type": "string",
          "minLength": 1,
          "maxLength": 128,
          "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"
        },
        "subject": {
          "type": "object",
          "required": [
            "rdns",
            "alternative_names"
          ],
          "additionalProperties": false,
          "properties": {
            "rdns": {
              "type": "array",
              "items": {
                "type": "object",
                "required": [
                  "oid",
                  "value"
                ],
                "additionalProperties": false,
                "properties": {
                  "oid": {
                    "type": "string",
                    "minLength": 3,
                    "maxLength": 128
                  },
                  "value": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 256
                  }
                }
              },
              "maxItems": 8,
              "minItems": 1,
              "uniqueItems": true
            },
            "alternative_names": {
              "type": "array",
              "items": {
                "type": "object",
                "required": [
                  "kind",
                  "value"
                ],
                "additionalProperties": false,
                "properties": {
                  "kind": {
                    "enum": [
                      "DNS",
                      "EMAIL",
                      "URI"
                    ]
                  },
                  "value": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 256
                  }
                }
              },
              "maxItems": 8,
              "minItems": 0,
              "uniqueItems": true
            }
          }
        },
        "rsa_bits": {
          "enum": [
            2048,
            3072,
            4096
          ]
        },
        "authority_seconds": {
          "type": "integer",
          "minimum": 1,
          "maximum": 86400
        },
        "reconciliation_seconds": {
          "type": "integer",
          "minimum": 1,
          "maximum": 604800
        },
        "maximum_polls": {
          "type": "integer",
          "minimum": 1,
          "maximum": 32
        }
      }
    },
    "estProfile": {
      "oneOf": [
        {
          "type": "object",
          "required": [
            "provider",
            "profile",
            "correlation",
            "request_contract"
          ],
          "additionalProperties": false,
          "properties": {
            "provider": {
              "type": "string",
              "minLength": 1,
              "maxLength": 128,
              "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"
            },
            "profile": {
              "type": "string",
              "minLength": 1,
              "maxLength": 128,
              "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"
            },
            "correlation": {
              "const": "NONE"
            },
            "request_contract": {
              "const": "NATIVE_SYNCHRONOUS"
            }
          }
        },
        {
          "type": "object",
          "required": [
            "provider",
            "profile",
            "correlation",
            "request_contract",
            "maximum_continuations",
            "repeat_registration"
          ],
          "additionalProperties": false,
          "properties": {
            "provider": {
              "type": "string",
              "minLength": 1,
              "maxLength": 128,
              "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"
            },
            "profile": {
              "type": "string",
              "minLength": 1,
              "maxLength": 128,
              "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"
            },
            "correlation": {
              "const": "NONE"
            },
            "request_contract": {
              "const": "REGISTERED_STATIC_CSR_REPEAT"
            },
            "maximum_continuations": {
              "type": "integer",
              "minimum": 1,
              "maximum": 32
            },
            "repeat_registration": {
              "type": "object",
              "required": [
                "contract_id",
                "contract"
              ],
              "additionalProperties": false,
              "description": "Trusted installation registration backed by an owner-only pinned local contract document. Config-check validates references only; online preflight verifies document/hash and exact endpoint/provider/profile/budget. The record asserts separately verified remote semantics; it is not proof supplied by HTTP202.",
              "properties": {
                "contract_id": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 128,
                  "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"
                },
                "contract": {
                  "$ref": "#/$defs/publicFile"
                }
              }
            }
          }
        }
      ]
    },
    "estProvisioning": {
      "type": "object",
      "required": [
        "requester",
        "subject_reference",
        "subject",
        "rsa_bits",
        "authority_seconds",
        "reconciliation_seconds"
      ],
      "additionalProperties": false,
      "properties": {
        "requester": {
          "type": "string",
          "minLength": 1,
          "maxLength": 128,
          "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"
        },
        "subject_reference": {
          "type": "string",
          "minLength": 1,
          "maxLength": 128,
          "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"
        },
        "subject": {
          "type": "object",
          "required": [
            "rdns",
            "alternative_names"
          ],
          "additionalProperties": false,
          "properties": {
            "rdns": {
              "type": "array",
              "items": {
                "type": "object",
                "required": [
                  "oid",
                  "value"
                ],
                "additionalProperties": false,
                "properties": {
                  "oid": {
                    "type": "string",
                    "minLength": 3,
                    "maxLength": 128
                  },
                  "value": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 256
                  }
                }
              },
              "maxItems": 8,
              "minItems": 1,
              "uniqueItems": true
            },
            "alternative_names": {
              "type": "array",
              "items": {
                "type": "object",
                "required": [
                  "kind",
                  "value"
                ],
                "additionalProperties": false,
                "properties": {
                  "kind": {
                    "enum": [
                      "DNS",
                      "EMAIL",
                      "URI"
                    ]
                  },
                  "value": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 256
                  }
                }
              },
              "maxItems": 8,
              "minItems": 0,
              "uniqueItems": true
            }
          }
        },
        "rsa_bits": {
          "enum": [
            2048,
            3072,
            4096
          ]
        },
        "authority_seconds": {
          "type": "integer",
          "minimum": 1,
          "maximum": 86400
        },
        "reconciliation_seconds": {
          "type": "integer",
          "minimum": 1,
          "maximum": 604800
        }
      }
    },
    "estAuthentication": {
      "oneOf": [
        {
          "type": "object",
          "required": [
            "type",
            "not_before",
            "expires_at"
          ],
          "additionalProperties": false,
          "properties": {
            "type": {
              "const": "MTLS"
            },
            "not_before": {
              "type": "string",
              "minLength": 1,
              "maxLength": 4096,
              "format": "date-time"
            },
            "expires_at": {
              "type": "string",
              "minLength": 1,
              "maxLength": 4096,
              "format": "date-time"
            }
          }
        },
        {
          "type": "object",
          "required": [
            "type",
            "not_before",
            "expires_at",
            "username",
            "secret_file"
          ],
          "additionalProperties": false,
          "properties": {
            "type": {
              "const": "BASIC"
            },
            "not_before": {
              "type": "string",
              "minLength": 1,
              "maxLength": 4096,
              "format": "date-time"
            },
            "expires_at": {
              "type": "string",
              "minLength": 1,
              "maxLength": 4096,
              "format": "date-time"
            },
            "username": {
              "type": "string",
              "minLength": 1,
              "maxLength": 128
            },
            "secret_file": {
              "type": "string",
              "minLength": 1,
              "maxLength": 4096
            }
          }
        }
      ]
    }
  },
  "$comment": "Initial provisioning and staging use the selected REST/SCEP/EST protocol. Software activation requires protected PKCS12 credentials, original verify-full database references and owner-only files."
}
