Troubleshooting
Why Event Grid MQTT fails certificate verify on a Flexy
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
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:
- 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.
- Record the full presented chain: the leaf issuer, the intermediate issuers and the root.
- 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.
- 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.
- 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.

