I am trying to use DCAppAttestService in Xamarin.iOS to attest a key generatd with GenerateKeyAsync() in a real iOS device, but it is failing with this error:
The operation couldn’t be completed. (com.apple.devicecheck.error error 2.) Specified argument was out of the range of valid values. (Parameter 'Platform name: 5.')
Here is my code:
public async Task<byte[]> GetAttestObject(string Challenge)
{
DCAppAttestService atserv = DCAppAttestService.SharedService;
try
{
if (atserv.Supported)
{
var keyId = await atserv.GenerateKeyAsync();
var Sha256Challenge=Sha256(Challenge);//custom metod to hash.
var HashValue = NSData.FromString(Sha256Challenge);
var vas = await atserv.AttestKeyAsync(keyId, HashValue); //Error thrown here
MemoryStream ms = new MemoryStream();
vas.AsStream().CopyTo(ms);
return ms.ToArray();
}
else
return null;
}
catch (Exception ex)
{
var S = ex.Message;
return null;
}
}
I cannot find any example of using this service in Xamarin.iOS anywhere.
I can generate a device token without problems using: var tkn = await DCDevice.CurrentDevice.GenerateTokenAsync();
Can anyone tell me what I am doing wrong or show me a sample code to obtain the attest object?