How to fix SSL: CERTIFICATE_VERIFY_FAILED on my PC

Yoga 41 Reputation points
2023-03-27T11:31:41.4366667+00:00

When sending a message from the device to the cloud through Azure CLI I get the error SSL Certificate to verify failure from my PC.

Command

az iot device send-d2c-message -n MY-STAGE-IOT-HUB -d 01118 --data 'Test Message'

Out Put

[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:852)

Can you suggest a way to fix this issue in a development environment?

Some more info

$ az --version

azure-cli 2.11.1

core 2.11.1

telemetry 1.0.5

Extensions:

azure-iot 0.10.0

Python location 'C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\python.exe'

Extensions directory 'C:\Users\MyPC.azure\cliextensions'

Python (Windows) 3.6.8 (tags/v3.6.8:3c6b436a57, Dec 23 2018, 23:31:17) [MSC v.1916 32 bit (Intel)]

Legal docs and information: aka.ms/AzureCliLegal

Unable to check if your CLI is up-to-date. Check your internet connection.

Please let us know how we are doing: https://aka.ms/azureclihats

and let us know if you're interested in trying out our newest features: https://aka.ms/CLIUXstudy

Azure IoT Hub
Azure IoT Hub
An Azure service that enables bidirectional communication between internet of things (IoT) devices and applications.
1,272 questions
{count} votes

Accepted answer
  1. Sander van de Velde | MVP 36,766 Reputation points MVP Volunteer Moderator
    2023-03-27T16:35:56.3966667+00:00

    Hello @Yoga,

    I tried to send a message myself:

    az iot device send-d2c-message --device-id clidevice --hub-name edge-check-weu-ih --data {\"e\":42} --properties 'a=1;b=2' -o json
    

    I did not encounter any problems, although my IoT is still using the old Baltimore TLS certificate (which is almost deprecated).

    This gave me this IoT Explorer positive feedback:

    User's image

    Notice, this is a tool for testing purposes only, you do not need to pass any device security credentials. This is because the CLI tool is running within the context of your subscription login account.


    If the response helped, do "Accept Answer". If it doesn't work, please let us know the progress. All community members with similar issues will benefit by doing so. Your contribution is highly appreciated.

    1 person found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. AshokPeddakotla-MSFT 35,971 Reputation points Moderator
    2023-03-27T14:04:42.7333333+00:00

    Yoga Welcome to Microsoft Q&A forum!

    [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:852)

    The error message indicates that the SSL certificate verification failed. Are you not using any certificate? Is this a simulated device?

    Can you suggest a way to fix this issue in a development environment?

    To fix this issue in a development environment, you can use a self-signed certificate. You can create a self-signed certificate using OpenSSL and then use it to authenticate your device. Please check the below documentations for detailed steps to create a self-signed certificate using OpenSSL.

    Create a self-signed certificate

    Use OpenSSL to create test certificates

    Create test certificate using OpenSSL and Azure IoT Hub

    Once certificate is generated and copied to the device, Use the --cert and --key flags to specify the path to the certificate and private key files when you run the az iot device send-d2c-message command:

    See az iot device send-d2c-message for parameters.

    Hope this helps. Do let us know if you need any further help.


    If this answers your query, do click Accept Answer and Yes for this answer as helpful. And, if you have any further query do let us know by commenting in the below section, happy to help!


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.