"vanilla" ssl connections work, but assigning a cert to the server and a client cert causes "ssl protocol failures", sometimes obscure version mismatch errors.
On investigation it turns out the that problem is in viossl.c and how ssl errors are handled.
ssl_should_retry calls SSL_get_error to check for the current error, but the documentation for SSL_get_error says:
"The current thread's
error queue must be empty before the TLS/SSL I/O operation is
attempted, or SSL_get_error() will not work reliably."
(attaching segment of mysqld.trace of the working, patched version...note how X509_R_CERT_ALREADY_IN_HASH_TABLE
errors get dropped by the patched code; otherwise they would cause a fatal error in the SSL connection, even though they are harmless, coming from the X509 certs being taken from both the server and the client)
It took a couple of iterations to clean up these errors, because there was some race conditions on when the errors came in vs. when they get handled in the code.
Solution: add ERR_clear_error() before each SSL_(read|write|etc) calls. And check for whatever errors are in the "queue" in the ssl_should_retry routine. The mysqld.trace shows that sometimes several errors are queued up, so just dismissing the first one won't be enough.
Patch attached; it has some extra whitespace changes, and extra DBUG_PRINT's for diagnostics
NOTE: v10.6 viossl.c has the same code in the 10.2 viossl.c, with minor changes that do not alter the problem noted in this bugreport
- relates to
-
MDEV-20404
Validation of SSL server certificate failed
-
-
Closed
{"report":{"fcp":1728.9000000953674,"ttfb":326.19999980926514,"pageVisibility":"visible","entityId":91730,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":0.5,"journeyId":"9e1dac45-10d3-4f71-9497-6d613a852fe6","navigationType":0,"readyForUser":1857,"redirectCount":0,"resourceLoadedEnd":1998.6999998092651,"resourceLoadedStart":332.5,"resourceTiming":[{"duration":494.09999990463257,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":332.5,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":332.5,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":826.5999999046326,"responseStart":0,"secureConnectionStart":0},{"duration":494.30000019073486,"initiatorType":"link","name":"https://jira.mariadb.org/s/7ebd35e77e471bc30ff0eba799ebc151-CDN/lu2cib/820016/12ta74/494e4c556ecbb29f90a3d3b4f09cb99c/_/download/contextbatch/css/jira.browse.project,project.issue.navigator,jira.view.issue,jira.general,jira.global,atl.general,-_super/batch.css?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&slack-enabled=true&whisper-enabled=true","startTime":332.69999980926514,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":332.69999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":827,"responseStart":0,"secureConnectionStart":0},{"duration":761.6999998092651,"initiatorType":"script","name":"https://jira.mariadb.org/s/0917945aaa57108d00c5076fea35e069-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":332.90000009536743,"connectEnd":332.90000009536743,"connectStart":332.90000009536743,"domainLookupEnd":332.90000009536743,"domainLookupStart":332.90000009536743,"fetchStart":332.90000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":332.90000009536743,"responseEnd":1094.5999999046326,"responseStart":1094.5999999046326,"secureConnectionStart":332.90000009536743},{"duration":909.3000001907349,"initiatorType":"script","name":"https://jira.mariadb.org/s/2d8175ec2fa4c816e8023260bd8c1786-CDN/lu2cib/820016/12ta74/494e4c556ecbb29f90a3d3b4f09cb99c/_/download/contextbatch/js/jira.browse.project,project.issue.navigator,jira.view.issue,jira.general,jira.global,atl.general,-_super/batch.js?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&locale=en&slack-enabled=true&whisper-enabled=true","startTime":333.09999990463257,"connectEnd":333.09999990463257,"connectStart":333.09999990463257,"domainLookupEnd":333.09999990463257,"domainLookupStart":333.09999990463257,"fetchStart":333.09999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":333.09999990463257,"responseEnd":1242.4000000953674,"responseStart":1242.4000000953674,"secureConnectionStart":333.09999990463257},{"duration":913.2999997138977,"initiatorType":"script","name":"https://jira.mariadb.org/s/a9324d6758d385eb45c462685ad88f1d-CDN/lu2cib/820016/12ta74/c92c0caa9a024ae85b0ebdbed7fb4bd7/_/download/contextbatch/js/atl.global,-_super/batch.js?locale=en","startTime":333.5,"connectEnd":333.5,"connectStart":333.5,"domainLookupEnd":333.5,"domainLookupStart":333.5,"fetchStart":333.5,"redirectEnd":0,"redirectStart":0,"requestStart":333.5,"responseEnd":1246.7999997138977,"responseStart":1246.7999997138977,"secureConnectionStart":333.5},{"duration":913.6999998092651,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-en/jira.webresources:calendar-en.js","startTime":333.59999990463257,"connectEnd":333.59999990463257,"connectStart":333.59999990463257,"domainLookupEnd":333.59999990463257,"domainLookupStart":333.59999990463257,"fetchStart":333.59999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":333.59999990463257,"responseEnd":1247.2999997138977,"responseStart":1247.2999997138977,"secureConnectionStart":333.59999990463257},{"duration":914,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-localisation-moment/jira.webresources:calendar-localisation-moment.js","startTime":333.7999997138977,"connectEnd":333.7999997138977,"connectStart":333.7999997138977,"domainLookupEnd":333.7999997138977,"domainLookupStart":333.7999997138977,"fetchStart":333.7999997138977,"redirectEnd":0,"redirectStart":0,"requestStart":333.7999997138977,"responseEnd":1247.7999997138977,"responseStart":1247.7999997138977,"secureConnectionStart":333.7999997138977},{"duration":928.2999997138977,"initiatorType":"link","name":"https://jira.mariadb.org/s/b04b06a02d1959df322d9cded3aeecc1-CDN/lu2cib/820016/12ta74/a2ff6aa845ffc9a1d22fe23d9ee791fc/_/download/contextbatch/css/jira.global.look-and-feel,-_super/batch.css","startTime":333.90000009536743,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":333.90000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1262.1999998092651,"responseStart":0,"secureConnectionStart":0},{"duration":913,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":335.19999980926514,"connectEnd":335.19999980926514,"connectStart":335.19999980926514,"domainLookupEnd":335.19999980926514,"domainLookupStart":335.19999980926514,"fetchStart":335.19999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":335.19999980926514,"responseEnd":1248.1999998092651,"responseStart":1248.1999998092651,"secureConnectionStart":335.19999980926514},{"duration":926.7999997138977,"initiatorType":"link","name":"https://jira.mariadb.org/s/3ac36323ba5e4eb0af2aa7ac7211b4bb-CDN/lu2cib/820016/12ta74/d176f0986478cc64f24226b3d20c140d/_/download/contextbatch/css/com.atlassian.jira.projects.sidebar.init,-_super,-project.issue.navigator,-jira.view.issue/batch.css?jira.create.linked.issue=true","startTime":335.5,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":335.5,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1262.2999997138977,"responseStart":0,"secureConnectionStart":0},{"duration":913.1999998092651,"initiatorType":"script","name":"https://jira.mariadb.org/s/5d5e8fe91fbc506585e83ea3b62ccc4b-CDN/lu2cib/820016/12ta74/d176f0986478cc64f24226b3d20c140d/_/download/contextbatch/js/com.atlassian.jira.projects.sidebar.init,-_super,-project.issue.navigator,-jira.view.issue/batch.js?jira.create.linked.issue=true&locale=en","startTime":335.59999990463257,"connectEnd":335.59999990463257,"connectStart":335.59999990463257,"domainLookupEnd":335.59999990463257,"domainLookupStart":335.59999990463257,"fetchStart":335.59999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":335.59999990463257,"responseEnd":1248.7999997138977,"responseStart":1248.7999997138977,"secureConnectionStart":335.59999990463257},{"duration":1623.2999997138977,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-js/jira.webresources:bigpipe-js.js","startTime":336.5,"connectEnd":336.5,"connectStart":336.5,"domainLookupEnd":336.5,"domainLookupStart":336.5,"fetchStart":336.5,"redirectEnd":0,"redirectStart":0,"requestStart":336.5,"responseEnd":1959.7999997138977,"responseStart":1959.7999997138977,"secureConnectionStart":336.5},{"duration":1622.7000002861023,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-init/jira.webresources:bigpipe-init.js","startTime":337.69999980926514,"connectEnd":337.69999980926514,"connectStart":337.69999980926514,"domainLookupEnd":337.69999980926514,"domainLookupStart":337.69999980926514,"fetchStart":337.69999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":337.69999980926514,"responseEnd":1960.4000000953674,"responseStart":1960.4000000953674,"secureConnectionStart":337.69999980926514},{"duration":117,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":1274.9000000953674,"connectEnd":1274.9000000953674,"connectStart":1274.9000000953674,"domainLookupEnd":1274.9000000953674,"domainLookupStart":1274.9000000953674,"fetchStart":1274.9000000953674,"redirectEnd":0,"redirectStart":0,"requestStart":1274.9000000953674,"responseEnd":1391.9000000953674,"responseStart":1391.9000000953674,"secureConnectionStart":1274.9000000953674},{"duration":333.5,"initiatorType":"link","name":"https://jira.mariadb.org/s/d5715adaadd168a9002b108b2b039b50-CDN/lu2cib/820016/12ta74/be4b45e9cec53099498fa61c8b7acba4/_/download/contextbatch/css/jira.project.sidebar,-_super,-project.issue.navigator,-jira.general,-jira.browse.project,-jira.view.issue,-jira.global,-atl.general,-com.atlassian.jira.projects.sidebar.init/batch.css?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&slack-enabled=true&whisper-enabled=true","startTime":1665.1999998092651,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":1665.1999998092651,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1998.6999998092651,"responseStart":0,"secureConnectionStart":0},{"duration":322.30000019073486,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/e65b778d185daf5aee24936755b43da6/_/download/contextbatch/js/browser-metrics-plugin.contrib,-_super,-project.issue.navigator,-jira.view.issue,-atl.general/batch.js?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&slack-enabled=true&whisper-enabled=true","startTime":1666.1999998092651,"connectEnd":1666.1999998092651,"connectStart":1666.1999998092651,"domainLookupEnd":1666.1999998092651,"domainLookupStart":1666.1999998092651,"fetchStart":1666.1999998092651,"redirectEnd":0,"redirectStart":0,"requestStart":1666.1999998092651,"responseEnd":1988.5,"responseStart":1988.5,"secureConnectionStart":1666.1999998092651},{"duration":324.19999980926514,"initiatorType":"script","name":"https://jira.mariadb.org/s/097ae97cb8fbec7d6ea4bbb1f26955b9-CDN/lu2cib/820016/12ta74/be4b45e9cec53099498fa61c8b7acba4/_/download/contextbatch/js/jira.project.sidebar,-_super,-project.issue.navigator,-jira.general,-jira.browse.project,-jira.view.issue,-jira.global,-atl.general,-com.atlassian.jira.projects.sidebar.init/batch.js?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&locale=en&slack-enabled=true&whisper-enabled=true","startTime":1666.5999999046326,"connectEnd":1666.5999999046326,"connectStart":1666.5999999046326,"domainLookupEnd":1666.5999999046326,"domainLookupStart":1666.5999999046326,"fetchStart":1666.5999999046326,"redirectEnd":0,"redirectStart":0,"requestStart":1666.5999999046326,"responseEnd":1990.7999997138977,"responseStart":1990.7999997138977,"secureConnectionStart":1666.5999999046326}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":171,"responseStart":326,"responseEnd":327,"domLoading":330,"domInteractive":2044,"domContentLoadedEventStart":2044,"domContentLoadedEventEnd":2093,"domComplete":3327,"loadEventStart":3328,"loadEventEnd":3329,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":2009.5999999046326},{"name":"bigPipe.sidebar-id.end","time":2010.5999999046326},{"name":"bigPipe.activity-panel-pipe-id.start","time":2010.6999998092651},{"name":"bigPipe.activity-panel-pipe-id.end","time":2013.4000000953674},{"name":"activityTabFullyLoaded","time":2102.7999997138977}],"measures":[],"correlationId":"305e1232887f58","effectiveType":"4g","downlink":10,"rtt":0,"serverDuration":100,"dbReadsTimeInMs":16,"dbConnsTimeInMs":25,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}