Search code examples
azurex509certificateazure-iot-edge

Azure IoT Edge: Edge Agent can't add X509 certificate to the store


I am trying to setup my azure iot edge device (Linux Ubuntu 18.04 - Linux Containers), but as soon as I apply the configuration with the Connectionstring my EdgeAgent fails on first provisioning with the following error message

System.Security.Cryptography.CryptographicException: The X509 certificate could not be added to the store.
 ---> System.UnauthorizedAccessException: Access to the path '/home/edgeagentuser/.dotnet/corefx/cryptography/x509stores/root' is denied.
 ---> System.IO.IOException: Permission denied
   --- End of inner exception stack trace ---
   at System.IO.FileSystem.CreateDirectory(String fullPath)
   at System.IO.Directory.CreateDirectory(String path)
   at Internal.Cryptography.Pal.DirectoryBasedStoreProvider.AddCertToStore(ICertificatePal certPal)
   at Internal.Cryptography.Pal.DirectoryBasedStoreProvider.Add(ICertificatePal certPal)
   --- End of inner exception stack trace ---
   at Internal.Cryptography.Pal.DirectoryBasedStoreProvider.Add(ICertificatePal certPal)
   at System.Security.Cryptography.X509Certificates.X509Store.Add(X509Certificate2 certificate)
   at Microsoft.Azure.Devices.Edge.Util.CertificateHelper.InstallCertificates(IEnumerable`1 certificateChain, ILogger logger) in /mnt/vss/_work/1/s/edge-util/src/Microsoft.Azure.Devices.Edge.Util/CertificateHelper.cs:line 228
   at Microsoft.Azure.Devices.Edge.Agent.Service.Program.MainAsync(IConfiguration configuration) in /mnt/vss/_work/1/s/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.Service/Program.cs:line 187

More details can be found here: GitHub Issue


Solution

  • Managed to resolve the issue, by specifying the edgeHub and edgeAgent container versions explicitly. Check Github issue for more detail.