Reputation: 1008
This should work, but my strings are null
/Get the details for this group
EnrollmentGroup group = await provisioningClient.GetEnrollmentGroupAsync(groupId);
logger.LogInformation("Got Enrollment Group: {group}", JsonConvert.SerializeObject(group));
var attestation =(SymmetricKeyAttestation)group.Attestation;
var primaryKey = attestation.PrimaryKey;
var secondaryKey = attestation.SecondaryKey;
if(string.IsNullOrEmpty(primaryKey))
logger.LogWarning("No Primary Key");
if(string.IsNullOrEmpty(secondaryKey))
logger.LogWarning("No Secondary Key");
logger.LogInformation("Got Keys {pri} and {sec}", primaryKey, secondaryKey);
GetEnrollmentGroupAsync(string) seems to work. It returns an enrollmeent group that has a symmetric key attestation.
Per the docs, there is a getter for those.
Upvotes: 0
Views: 51
Reputation: 1008
The correct Call is GetEnrollmentGroupAttestationAsync
var attestationMechanism = await provisioningClient.GetEnrollmentGroupAttestationAsync(groupId);
var attestation = (SymmetricKeyAttestation)attestationMechanism.GetAttestation();
string primaryKey = attestation.PrimaryKey;
string secondaryKey = attestation.SecondaryKey;
This assumes it was a SymmetricKeyAttestation. AttestationMethod has a Type
property if you need to determine type dynamically.
Upvotes: 1