Failed Microsoft.Azure.Devices.E2ETests.FileUploadE2ETests.FileUpload_X509_SmallFile_Http
Error Message:
Test method Microsoft.Azure.Devices.E2ETests.FileUploadE2ETests.FileUpload_X509_SmallFile_Http threw exception:
System.NullReferenceException: Object reference not set to an instance of an object.
Stack Trace:
at Microsoft.Azure.Devices.Client.IotHubConnectionString.Microsoft.Azure.Devices.Client.IAuthorizationProvider.GetPasswordAsync() in D:\jenkins\workspace\csharp-windows-wip\device\Microsoft.Azure.Devices.Client\IotHubConnectionString.Core.cs:line 22
at Microsoft.Azure.Devices.Client.Transport.HttpClientHelper.
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Azure.Devices.Client.Transport.HttpClientHelper.
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Azure.Devices.Client.Transport.HttpTransportHandler.
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Azure.Devices.E2ETests.FileUploadE2ETests.
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Azure.Devices.E2ETests.FileUploadE2ETests.
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
This is failing on NetCore E2E runs only.
This bug makes the library unusable for x509 authentication with file upload and can be traced to device/Microsoft.Azure.Devices.Client/Transport/HttpClientHelper.cs line 73 (constructor) and 415 (ExecuteAsync).
When the constructor finds itself in a uwp, plc or netstandard1.3 (for core) it ignores whether you have a certificate - so when you get to ExecuteAsync you skip over using the certificate and try and create a password which, because there is no token refresher, throws the above exception.
I've altered the section in my own code to use an HttpClientHandlerin the #else block and managed to successfully upload a file, but I'm more than a bit new to the open source community so haven't made a change to the repository yet.
The change is as follows:
(from line 62 HttpClientHelper.cs)
HttpClientHandler handler = null;
if (clientCert != null)
{
handler = new WebRequestHandler();
(handler as WebRequestHandler).ClientCertificates.Add(clientCert);
this.usingX509ClientCert = true;
}
if (clientCert != null)
{
handler = new HttpClientHandler
{
ClientCertificateOptions = ClientCertificateOption.Manual,
};
(handler as HttpClientHandler).ClientCertificates.Add(clientCert);
this.usingX509ClientCert = true;
}
this.httpClientObj = handler != null ? new HttpClient(handler) : new HttpClient();
Thanks @labiraus for identifying the issue! Feel free to submit a PR with the change that also re-enables the test.
I'm more than a bit new to the open source community so haven't made a change to the repository yet.
If you'd like to make this change, start by Fork-ing this repo then cloning the fork on your machine. After you push the change to your fork, you will be able to create a Pull Request (using the GitHub website).
Closing as it is linked to issue #424
This issue still isn't resolved even though both this issue and the issue referenced (#424) are closed.
Any update on when this will be fixed?
Thanks @KasperHoldum: Looks like the test is still deactivated, pointing at this issue.