Closed IdanAviad closed 5 years ago
Can you please provide the code that you are using that gives you this exception? And can you share more information about the device that is running it? Is this windows, linux, etc? What versions of the provisioning dependencies are you using?
Hi, This is the code sample from the Azure IoT Samples for C# to simulate a TPM device on a development machine running the Windows OS: public static int Main(string[] args) { if (string.IsNullOrWhiteSpace(s_idScope) && (args.Length > 0)) { s_idScope = args[0]; }
if (string.IsNullOrWhiteSpace(s_idScope))
{
Console.WriteLine("ProvisioningDeviceClientTpm <IDScope>");
return 1;
}
// Remove if a real TPM is being used.
Console.WriteLine("Starting TPM simulator.");
SecurityProviderTpmSimulator.StartSimulatorProcess();
// Replace the following type with SecurityProviderTpmHsm() to use a real TPM2.0 device.
using (var security = new SecurityProviderTpmSimulator(RegistrationId))
// Select one of the available transports:
// To optimize for size, reference only the protocols used by your application.
using (var transport = new ProvisioningTransportHandlerHttp())
// using (var transport = new ProvisioningTransportHandlerAmqp(TransportFallbackType.TcpOnly))
// using (var transport = new ProvisioningTransportHandlerAmqp(TransportFallbackType.WebSocketOnly))
{
// Note that the TPM simulator will create an NVChip file containing the simulated TPM state.
Console.WriteLine("Extracting endorsement key.");
string base64EK = Convert.ToBase64String(security.GetEndorsementKey());
Console.WriteLine(
"In your Azure Device Provisioning Service please go to 'Manage enrollments' and select " +
"'Individual Enrollments'. Select 'Add' then fill in the following:");
Console.WriteLine("\tMechanism: TPM");
Console.WriteLine($"\tRegistration ID: {RegistrationId}");
Console.WriteLine($"\tEndorsement key: {base64EK}");
Console.WriteLine("\tDevice ID: iothubtpmdevice1 (or any other valid DeviceID)");
Console.WriteLine();
Console.WriteLine("Press ENTER when ready.");
Console.ReadLine();
ProvisioningDeviceClient provClient =
ProvisioningDeviceClient.Create(GlobalDeviceEndpoint, s_idScope, security, transport);
var sample = new ProvisioningDeviceClientSample(provClient, security);
sample.RunSampleAsync().GetAwaiter().GetResult(); //This is were I get the exception
}
return 0;
}
The Device is windows 10! What do you mean "Versions of the provisioning dependencies"? and were can I find it?
Thanks! Idan
When you add a nuget dependency to get the ProvisioningDeviceClient, you have to specify which version of the dependency you want. You can check your nuget package manager to find out which version you are using
Hi, I updated to the latest versions: Microsoft.Azure.Devices.Client: V1.21.1 Microsoft.Azure.Devices.Provisioning.Client: V1.4.0 Microsoft.Azure.Devices.Provisioning.Security.Tpm: V1.1.6 Microsoft.Azure.Devices.Provisioning.Transport.Amqp: V1.1.9 Microsoft.Azure.Devices.Provisioning.Transport.Http: V1.1.6 Microsoft.Azure.Devices.Provisioning.Transport.Mqtt: V1.1.8
Still, I get the same exception :(
Finally, I changed the transport layer from Http to Amqp and it worked! :) Why it doesn't work with Http? I do not know.
@IdanAviad, thank you for your contribution to our open-sourced project! Please help us improve by filling out this 2-minute customer satisfaction survey
Hello, I’m trying to follow the IOT Provisioning Quickstarts tutorial (Create and provision a simulated TPM device using C# device SDK for IoT Hub Device Provisioning Service) I keep getting the following exception while trying to enroll the simulated device. Can you please help me figuring what is the problem? I’m pretty sure that I entered a valid Endorsement key and Registration ID as displayed in the example command widow.
The Exception I get:
Microsoft.Azure.Devices.Provisioning.Client.ProvisioningTransportException HResult=0x80131500 Message=HTTP transport exception: malformed server error message: '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
Certificate verification error
Overview:
Access denied. Certificate validation failed for the following URL: global.azure-devices-provisioning.net
Details:
VERIFY DENY: depth=0, Client Certificate requested: "global.azure-devices-provisioning.net"
Options:
Pressing the button allows you to visit the website although the certificate is not valid.
Click to return to the previous page:
To find out more about why access was denied, please contact your administrator. The reference ID is 148.