IMD SolutionComputing LibraryShop main store

Troubleshooting

Why Event Grid MQTT fails certificate verify on a Flexy

Edge computing and IIoT Published 6 min read By IMD Solution engineering team

Short answer

The Flexy refused the Event Grid broker's server certificate: it could not build a trusted path from that certificate to the CA file named in the MQTT parameters. Your client certificate and key only authenticate the Flexy to Event Grid, and the responses 3 and 2 are local script results, not broker codes, because TLS failed before any MQTT packet was sent. Load the root CA that issued the broker certificate, then check the Flexy clock and hostname.

On this page
  1. What the error already tells you
  2. Two certificates with two different jobs
  3. Why the desktop client connects anyway
  4. Responses 3 and 2 are local results, not broker codes
  5. Inspect the chain the broker actually presents
  6. Clock and hostname after the CA file
  7. The decision
  8. Questions asked

Your Flexy is not failing at MQTT and not failing at client authentication. The function named in the log, ssl3_get_server_certificate, is the step where the Flexy validates the broker's server certificate against the CA file you configured, and certificate verify failed means it refused that certificate locally. The client certificate and private key from the quickstart only identify the Flexy to Event Grid; they cannot make the Flexy trust the server, and a desktop client that connects with the same pair proves nothing about your CA file. The responses 3 and 2 are local results of the script's connect call, because TLS died before a single MQTT packet was exchanged. Fix the CA file first, then the clock, then the hostname, in that order.

What the error already tells you #

The line to work from is:

Log (08): OpenSSL Error[0]: error:14090086:SSL routines : ssl3_get_server_certificate:certificate verify failed

Every part of it places the failure. SSL routines is the local TLS library, ssl3_get_server_certificate is the processing of the server's certificate message, and the refusal happens on the Flexy, inside the handshake. From that one line you can close stages and open suspects:

  • Already past: name resolution returned an address, the TCP connection to the broker port was established, and the server delivered its certificate. A dead cable, a wrong route or a blocked firewall cannot produce this message.
  • Not reached: the Flexy never got far enough to present its own client certificate, and no MQTT CONNECT was sent. Client authentication, topic permissions and the Event Grid client settings are innocent until TLS is up.
  • Still suspect, in order of likelihood: the CA file content (wrong issuer), a missing intermediate certificate, the Flexy system clock, and the hostname you connect with.

The sections below take those four suspects in that order.

Two certificates with two different jobs #

Nearly every instance of this error is role confusion, so fix the roles first:

Item Lives where Checked by A failure looks like
Client certificate and private key the MQTT parameters on the Flexy Event Grid, against the CA registered in the namespace an MQTT-level rejection, after TLS is up
CA file (CAFILE in the MQTT parameters) a file on the Flexy the Flexy itself, while verifying the server OpenSSL error 14090086, during the handshake

Microsoft documents Event Grid client authentication with X.509 certificates that the namespace validates against a registered CA through certificate-chain validation schemes. That is where the CA created in the quickstart belongs: it signs the client certificate, and the namespace uses it to admit your Flexy. It has no relationship to the CA that issued the broker's server certificate. Loading the quickstart CA as the CA file is the most common cause of this exact error, because the Flexy then holds a trust anchor that cannot vouch for anything the broker presents. The same issuing-CA-versus-trusted-root split appears in how a TIA Portal MQTT TLS setup separates issuing CAs from trusted roots, and the rule is identical on both platforms.

Why the desktop client connects anyway #

The desktop client validates the server against the operating system's trust store, where the public roots are already installed; the Flexy trusts exactly the file you pass it, nothing more. Same certificate pair, different server-trust path. So the working desktop connection proves one thing only: the broker accepts your client certificate and key. Leave that pair untouched until TLS completes on the Flexy. Small controllers without an operating-system trust store behave like the Flexy, not like the desktop, which is why an Opta controller's HTTPS GET needs an explicit trusted CA file.

Responses 3 and 2 are local results, not broker codes #

Because verification failed inside the handshake, no MQTT CONNECT was transmitted and no CONNACK came back, so there is no broker return code to decode — matching those two numbers against MQTT reason-code tables is wasted time. Both come from the Flexy script's connect call: with a CA file, verification ran and failed; without one, the Flexy has no trust anchor at all — it requires a CA certificate for MQTT over TLS — and the attempt fails on a different local path. Removing the file does not skip verification, it only changes the failure. For reading the connection state from the script side, see checking MQTT connection status in an Ewon Flexy BASIC script.

Inspect the chain the broker actually presents #

Work from evidence, not from assumptions:

  1. From a machine that connects successfully, run a TLS chain inspection against the same namespace hostname. Microsoft documents TCP port 8883 for MQTT v3.1.1 and MQTT v5 on the Event Grid broker; take the hostname and port from your namespace configuration rather than carrying over a port from another broker.
  2. Record the full presented chain: the leaf issuer, the intermediate issuers and the root.
  3. Download that root CA certificate in PEM form from the issuing CA's official distribution page. Do not export trust material out of the desktop client and do not reuse the quickstart CA.
  4. If the broker leaves an intermediate out of the handshake, the file must supply it; the Flexy reference documentation states whether several PEM blocks in one file are accepted, so confirm that before concatenating anything.
  5. Verify that the path in the CA file parameter resolves to the intended readable file on the Flexy, then retry and read the log.

Clock and hostname after the CA file #

Validation also checks dates and names, so two faults produce the identical error with a perfect CA file:

  • Clock: read the Flexy system time and compare it with the root certificate's validity window. Worked example, hypothetical: after a power cut the clock reads 2023-06-01 while the root is valid from 2024-03-11. From June 2023 to 11 March 2024 is 30+31+31+30+31+30+31+31+29+10 = 284 days, so the clock sits that far before the window opens and every attempt must fail with the same verify error. Set the time from a time server and retry.
  • Hostname: connect with the namespace's MQTT hostname exactly as the namespace configuration shows it. The broker certificate is issued for that name, so connecting by IP address fails verification the same way; that case is covered in why a Flexy MQTT TLS connection fails when the certificate lacks the broker DNS name, with the related IP-versus-hostname behavior in why an Ewon Flexy 205 publishes MQTT by IP but not hostname.

The decision #

  • The desktop client connects with the same pair and the Flexy logs the verify error: the CA file is wrong. Replace its content with the root that issued the broker certificate, plus any intermediate the handshake omits, obtained from the issuer's official channel.
  • The error persists with a verified chain: set the Flexy clock from a time server, then connect with the namespace hostname instead of an address.
  • The OpenSSL line is gone: TLS is up, and any remaining rejection is MQTT-level — client authentication against the CA registered in the namespace, then permissions. Trace those stages in tracing an edge gateway MQTT connection failure to Azure Event Grid.
  • Do not treat removing the CA file as a workaround: it yields the response 2 and no session, and a client that skips server verification on an OT network would accept any broker that answers.

Questions asked

Does the Flexy transmit the client certificate during the failing attempts?

No. The client verifies the server certificate before it presents its own certificate, so in every attempt that logged the verify error the quickstart certificate and key never left the Flexy. That is why re-exporting or reissuing the client pair cannot change this error: the broker never saw the client at all. Edit the CA file instead and leave the client pair exactly as it is.

Where is the quickstart CA actually used?

On the Event Grid side. The certificate-chain client authentication registers your CA or its chain in the namespace, and the broker checks the certificate the Flexy presents against it using the validation scheme chosen there. That check runs after TLS is established and can only produce MQTT-level rejections, never an OpenSSL verify error on the Flexy.

What changes in the log once the CA file is correct?

The OpenSSL line disappears and the connection either succeeds or fails at MQTT level, where CONNACK codes, client authentication and topic permissions become meaningful. Only then is a packet trace worth reading for application detail, because everything before that point is encrypted handshake traffic that shows an exchange took place but not what it contained.

Can a wrong desktop setting explain the successful comparison connection?

Yes. If server verification was switched off in the desktop test client, its successful connection says nothing about trust and only proves the broker accepts the client pair. Check that setting before treating the desktop result as evidence, and compare the verification mode and CA source the desktop client used with the file the Flexy is given.

Keep reading

  • Troubleshooting

    Fixing an edge gateway MQTT TLS private key load failure

    The errors error:0906D06C PEM routines:PEM_read_bio:no start line and error:140B0009 SSL routines:SSL_CTX_use_PrivateKey_file mean the gateway cannot parse its own private-key file, so the failure is local and happens before the broker sees anything. On a Flexy 205 running firmware 15.0s1 the confirmed correction is the 15.0s2 firmware upgrade with the same certificate files, not new keys or AWS IoT policy edits.

    Edge computing and IIoT

  • Troubleshooting

    MQTT TLS connects but no CONNACK: find the failing hop

    The connect callback fires only when the broker returns a CONNACK, so with TCP ESTABLISHED and no callback the failure is in the TLS handshake or between TLS and MQTT. Run openssl s_client against the listener, then mosquitto_sub -d with the same CA file and credentials; wrong credentials are not the cause, because the broker answers those with a CONNACK that fires the callback with a return code.

    Edge computing and IIoT

  • Troubleshooting

    Why the Flexy AWS IoT script fails at MQTT CONNECT with error 28

    Error 28 at MQTT CONNECT does not mean the WAN is down: the script prints its WAN message for any LSTERR value 28. An SSL/TLS configuration event in the event log puts the fault at the TLS hop, so check the CA, certificate and key files, then port 8883 and the Flexy clock, before touching the AWS device policy.

    Edge computing and IIoT

Why oversized history blocks spike historian RAM at merge