Search code examples
azureazure-iot-hubazure-iot-edge

Getting error falling CreateServerCertificateAsync: Could not get server cert while using test certs at IoT Edge device(azure)


I am trying to enable certs at the IoT Edge device end I am using the demo certs but the iothub module is failing with below error

2021-04-27 02:08:48.364 +00:00 Edge Hub Main()
Unhandled exception. System.AggregateException: One or more errors occurred. (Error calling CreateServerCertificateAsync: Could not get server cert
    caused by: internal error)
 ---> Microsoft.Azure.Devices.Edge.Util.Edged.WorkloadCommunicationException- Message:Error calling CreateServerCertificateAsync: Could not get server cert
    caused by: internal error, StatusCode:500, at:   at Microsoft.Azure.Devices.Edge.Util.Edged.Version_2019_01_30.WorkloadClient.HandleException(Exception ex, String operation) in /home/vsts/work/1/s/edge-util/src/Microsoft.Azure.Devices.Edge.Util/edged/version_2019_01_30/WorkloadClient.cs:line 109
   at Microsoft.Azure.Devices.Edge.Util.Edged.WorkloadClientVersioned.Execute[T](Func`1 func, String operation) in /home/vsts/work/1/s/edge-util/src/Microsoft.Azure.Devices.Edge.Util/edged/WorkloadClientVersioned.cs:line 77
   at Microsoft.Azure.Devices.Edge.Util.Edged.Version_2019_01_30.WorkloadClient.CreateServerCertificateAsync(String hostname, DateTime expiration) in /home/vsts/work/1/s/edge-util/src/Microsoft.Azure.Devices.Edge.Util/edged/version_2019_01_30/WorkloadClient.cs:line 35
   at Microsoft.Azure.Devices.Edge.Util.CertificateHelper.GetServerCertificatesFromEdgelet(Uri workloadUri, String workloadApiVersion, String workloadClientApiVersion, String moduleId, String moduleGenerationId, String edgeHubHostname, DateTime expiration) in /home/vsts/work/1/s/edge-util/src/Microsoft.Azure.Devices.Edge.Util/CertificateHelper.cs:line 260
   at Microsoft.Azure.Devices.Edge.Hub.Service.EdgeHubCertificates.LoadAsync(IConfigurationRoot configuration, ILogger logger) in /home/vsts/work/1/s/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/EdgeHubCertificates.cs:line 54
   at Microsoft.Azure.Devices.Edge.Hub.Service.Program.MainAsync(IConfigurationRoot configuration) in /home/vsts/work/1/s/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Program.cs:line 54
   --- End of inner exception stack trace ---
   at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
   at System.Threading.Tasks.Task`1.get_Result()
   at Microsoft.Azure.Devices.Edge.Hub.Service.Program.Main() in /home/vsts/work/1/s/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Program.cs:line 33

Please find the config in /etc/aziot/config.toml file

trust_bundle_cert = "file:///home/azureuser/cert/certs/azure-iot-test-only.root.ca.cert.pem"
[edge_ca]
cert = "file:///home/azureuser/cert/certs/iot-edge-device-ca-test-device-ca-certs-full-chain.cert.pem"           
pk = "file:///home/azureuser/cert/certs/iot-edge-device-ca-test-device-ca-certs.cert.pem" 

[provisioning]
source = "manual"
connection_string ="HostName=XXXXXXXXX-dev.azure-devices.net;DeviceId=test-device;SharedAccessKey=XXXXXXXXXXXXXXXXXXXXXXXXXXXX"             

Solution

  • I made a mistake while mentioning the path to the root ca. The issue is resolved