Esempio n. 1
0
def create_individual_enrollment(registration_id, device_id=None):
    """
    Create an individual enrollment record using the service client
    :param registration_id: The registration id of the enrollment
    :param device_id:  Optional device id
    :return: And individual enrollment record
    """
    reprovision_policy = ReprovisionPolicy(migrate_device_data=True)
    attestation_mechanism = AttestationMechanism(type="symmetricKey")

    individual_provisioning_model = IndividualEnrollment.create(
        attestation=attestation_mechanism,
        registration_id=registration_id,
        device_id=device_id,
        reprovision_policy=reprovision_policy,
    )

    return service_client.create_or_update(individual_provisioning_model)
Esempio n. 2
0
def create_individual_enrollment_with_x509_client_certs(device_index, device_id=None):
    registration_id = device_common_name + str(device_index)
    reprovision_policy = ReprovisionPolicy(migrate_device_data=True)

    device_cert_input_file = "demoCA/newcerts/device_cert" + str(device_index) + ".pem"
    with open(device_cert_input_file, "r") as in_device_cert:
        device_cert_content = in_device_cert.read()

    attestation_mechanism = AttestationMechanism.create_with_x509_client_certs(device_cert_content)

    individual_provisioning_model = IndividualEnrollment.create(
        attestation=attestation_mechanism,
        registration_id=registration_id,
        reprovision_policy=reprovision_policy,
        device_id=device_id,
    )

    return service_client.create_or_update(individual_provisioning_model)