none
HttpClient handler could not recognize the credentials of the X509 Certificate RRS feed

  • Question

  • We're trying to deploy custom IoTEdge Module which creates new HttpClientHandler() and adds the X509Certificate certificate (pfx file) to it.

    httpClientHandler.ClientCertificates.Add(cert);

    Then it queries an API by creating the new instance of httpclient.

    using (var httpClient = new HttpClient(httpClientHandler)){}

    It then use httpClient.PutAsync.

    The code either hangs at PutAsync or it throws

    Exception The credentials supplied to the package were not recognized.

    Can someone point me where is the problem? (The code works fine when tested locally. The issue found when it's deployed as edge module (on Windows host, and using Windows containers)

    Monday, September 30, 2019 6:42 AM

Answers

  • Hello. I don't think this is an issue with Iot edge. Now I tried with docker container with admin user, and this error doesn't appear. But I'm not sure why this is necessary. I don't know if this is an workaround, or a fix for my issue, but I'm able to establish the connection with this. Thanks for the support. 
    • Marked as answer by Keshava GN Wednesday, October 30, 2019 3:51 AM
    Tuesday, October 15, 2019 1:59 AM
  • Hello Keshava,

    I am looking at this issue internally and we need some clarification:

    1) You tried it on a docker container with admin user, this is the IotEdge Module container has admin rights and the error is gone?

    2) Did you also tried it using a regular container (ie not as an Edge module) ? We suspect that if you don't give admin rights to the container you will face the same issue, if that's the case the issue is definitely not related with IoT Edge.

    Thanks!

    • Marked as answer by Keshava GN Wednesday, October 30, 2019 3:51 AM
    Friday, October 25, 2019 9:00 AM
    Moderator

All replies

  • Hi Keshava,

    Can you please let us know which sample are you following and in what step it failed?

    Thanks!

    Thursday, October 3, 2019 12:34 PM
    Moderator
  • Thursday, October 3, 2019 12:37 PM
    Moderator
  • Hello, Thanks for the response. Yes my issue is same, and I came across the link while searching. But there's no answer in that thread. So thought of posting it here on msdn.

    I'm not using a sample. This is our custom module which uses the httpClientHandler, but either hangs or throws exception at httpClient.PutAsync ..

    Thank you.

    Keshava G N

    Tuesday, October 8, 2019 10:56 AM
  • And I can see a comment on SO thread he could not get httpClientHander work with Edge. Is there a reason for that? Any pointers would be helpful. Thanks.
    Tuesday, October 8, 2019 10:59 AM
  • Thanks Keshava for the details. I am syncing with Mark to check if this is a bug and we are fixing it already.

    Please bear with me. Can you find any workaround for your implementation that will unblock you for now?

    Thank you!

    Tuesday, October 8, 2019 1:36 PM
    Moderator
  • No, I didn't find a workaround as of now. While we are trying to make this work, please let me know if you come across any solution.

    Thank you.

    Wednesday, October 9, 2019 3:47 AM
  • Hello Keshava,

    I am still in the process of trying to repro this. For now can you try and use C IoTEdge Module? 

    Thanks!

    Monday, October 14, 2019 3:20 PM
    Moderator
  • Hello. I don't think this is an issue with Iot edge. Now I tried with docker container with admin user, and this error doesn't appear. But I'm not sure why this is necessary. I don't know if this is an workaround, or a fix for my issue, but I'm able to establish the connection with this. Thanks for the support. 
    • Marked as answer by Keshava GN Wednesday, October 30, 2019 3:51 AM
    Tuesday, October 15, 2019 1:59 AM
  • Hello Keshava,

    I am looking at this issue internally and we need some clarification:

    1) You tried it on a docker container with admin user, this is the IotEdge Module container has admin rights and the error is gone?

    2) Did you also tried it using a regular container (ie not as an Edge module) ? We suspect that if you don't give admin rights to the container you will face the same issue, if that's the case the issue is definitely not related with IoT Edge.

    Thanks!

    • Marked as answer by Keshava GN Wednesday, October 30, 2019 3:51 AM
    Friday, October 25, 2019 9:00 AM
    Moderator
  • 1. Yes

    2. Yes, it's not related to IoT Edge.

    I'm closing the thread. Thanks for the support.

    Wednesday, October 30, 2019 3:51 AM