"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":1294.2999997138977,"ttfb":401.09999990463257,"pageVisibility":"visible","entityId":91730,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":16,"apdex":0.5,"journeyId":"d9b0df1b-2b14-4fd2-a824-8429e7559125","navigationType":0,"readyForUser":1355.5,"redirectCount":0,"resourceLoadedEnd":1370.2999997138977,"resourceLoadedStart":407,"resourceTiming":[{"duration":412.3999996185303,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2bu7/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":407,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":407,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":819.3999996185303,"responseStart":0,"secureConnectionStart":0},{"duration":412.5,"initiatorType":"link","name":"https://jira.mariadb.org/s/7ebd35e77e471bc30ff0eba799ebc151-CDN/lu2bu7/820016/12ta74/8679b4946efa1a0bb029a3a22206fb5d/_/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","startTime":407.2999997138977,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":407.2999997138977,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":819.7999997138977,"responseStart":0,"secureConnectionStart":0},{"duration":471.5,"initiatorType":"script","name":"https://jira.mariadb.org/s/fbf975c0cce4b1abf04784eeae9ba1f4-CDN/lu2bu7/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":407.3999996185303,"connectEnd":407.3999996185303,"connectStart":407.3999996185303,"domainLookupEnd":407.3999996185303,"domainLookupStart":407.3999996185303,"fetchStart":407.3999996185303,"redirectEnd":0,"redirectStart":0,"requestStart":407.3999996185303,"responseEnd":878.8999996185303,"responseStart":878.8999996185303,"secureConnectionStart":407.3999996185303},{"duration":536.1999998092651,"initiatorType":"script","name":"https://jira.mariadb.org/s/099b33461394b8015fc36c0a4b96e19f-CDN/lu2bu7/820016/12ta74/8679b4946efa1a0bb029a3a22206fb5d/_/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","startTime":407.5,"connectEnd":407.5,"connectStart":407.5,"domainLookupEnd":407.5,"domainLookupStart":407.5,"fetchStart":407.5,"redirectEnd":0,"redirectStart":0,"requestStart":407.5,"responseEnd":943.6999998092651,"responseStart":943.6999998092651,"secureConnectionStart":407.5},{"duration":539.6999998092651,"initiatorType":"script","name":"https://jira.mariadb.org/s/94c15bff32baef80f4096a08aceae8bc-CDN/lu2bu7/820016/12ta74/c92c0caa9a024ae85b0ebdbed7fb4bd7/_/download/contextbatch/js/atl.global,-_super/batch.js?locale=en","startTime":407.59999990463257,"connectEnd":407.59999990463257,"connectStart":407.59999990463257,"domainLookupEnd":407.59999990463257,"domainLookupStart":407.59999990463257,"fetchStart":407.59999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":407.59999990463257,"responseEnd":947.2999997138977,"responseStart":947.2999997138977,"secureConnectionStart":407.59999990463257},{"duration":540.1999998092651,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bu7/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-en/jira.webresources:calendar-en.js","startTime":407.59999990463257,"connectEnd":407.59999990463257,"connectStart":407.59999990463257,"domainLookupEnd":407.59999990463257,"domainLookupStart":407.59999990463257,"fetchStart":407.59999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":407.59999990463257,"responseEnd":947.7999997138977,"responseStart":947.7999997138977,"secureConnectionStart":407.59999990463257},{"duration":542.8000001907349,"initiatorType":"link","name":"https://jira.mariadb.org/s/b04b06a02d1959df322d9cded3aeecc1-CDN/lu2bu7/820016/12ta74/a2ff6aa845ffc9a1d22fe23d9ee791fc/_/download/contextbatch/css/jira.global.look-and-feel,-_super/batch.css","startTime":407.7999997138977,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":407.7999997138977,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":950.5999999046326,"responseStart":0,"secureConnectionStart":0},{"duration":540.9000000953674,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bu7/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-localisation-moment/jira.webresources:calendar-localisation-moment.js","startTime":407.7999997138977,"connectEnd":407.7999997138977,"connectStart":407.7999997138977,"domainLookupEnd":407.7999997138977,"domainLookupStart":407.7999997138977,"fetchStart":407.7999997138977,"redirectEnd":0,"redirectStart":0,"requestStart":407.7999997138977,"responseEnd":948.6999998092651,"responseStart":948.5999999046326,"secureConnectionStart":407.7999997138977},{"duration":541.4000000953674,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":407.8999996185303,"connectEnd":407.8999996185303,"connectStart":407.8999996185303,"domainLookupEnd":407.8999996185303,"domainLookupStart":407.8999996185303,"fetchStart":407.8999996185303,"redirectEnd":0,"redirectStart":0,"requestStart":407.8999996185303,"responseEnd":949.2999997138977,"responseStart":949.2999997138977,"secureConnectionStart":407.8999996185303},{"duration":542.8999996185303,"initiatorType":"link","name":"https://jira.mariadb.org/s/3ac36323ba5e4eb0af2aa7ac7211b4bb-CDN/lu2bu7/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":408,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":408,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":950.8999996185303,"responseStart":0,"secureConnectionStart":0},{"duration":541.7999997138977,"initiatorType":"script","name":"https://jira.mariadb.org/s/3339d87fa2538a859872f2df449bf8d0-CDN/lu2bu7/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":408.09999990463257,"connectEnd":408.09999990463257,"connectStart":408.09999990463257,"domainLookupEnd":408.09999990463257,"domainLookupStart":408.09999990463257,"fetchStart":408.09999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":408.09999990463257,"responseEnd":949.8999996185303,"responseStart":949.8999996185303,"secureConnectionStart":408.09999990463257},{"duration":956.0999999046326,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bu7/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-js/jira.webresources:bigpipe-js.js","startTime":413.69999980926514,"connectEnd":413.69999980926514,"connectStart":413.69999980926514,"domainLookupEnd":413.69999980926514,"domainLookupStart":413.69999980926514,"fetchStart":413.69999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":413.69999980926514,"responseEnd":1369.7999997138977,"responseStart":1369.7999997138977,"secureConnectionStart":413.69999980926514},{"duration":956.5,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bu7/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-init/jira.webresources:bigpipe-init.js","startTime":413.7999997138977,"connectEnd":413.7999997138977,"connectStart":413.7999997138977,"domainLookupEnd":413.7999997138977,"domainLookupStart":413.7999997138977,"fetchStart":413.7999997138977,"redirectEnd":0,"redirectStart":0,"requestStart":413.7999997138977,"responseEnd":1370.2999997138977,"responseStart":1370.2999997138977,"secureConnectionStart":413.7999997138977},{"duration":237.2999997138977,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":1094.0999999046326,"connectEnd":1094.0999999046326,"connectStart":1094.0999999046326,"domainLookupEnd":1094.0999999046326,"domainLookupStart":1094.0999999046326,"fetchStart":1094.0999999046326,"redirectEnd":0,"redirectStart":0,"requestStart":1094.0999999046326,"responseEnd":1331.3999996185303,"responseStart":1331.3999996185303,"secureConnectionStart":1094.0999999046326},{"duration":147.7000002861023,"initiatorType":"script","name":"https://www.google-analytics.com/analytics.js","startTime":1271.8999996185303,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":1271.8999996185303,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1419.5999999046326,"responseStart":0,"secureConnectionStart":0}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":284,"responseStart":401,"responseEnd":407,"domLoading":404,"domInteractive":1487,"domContentLoadedEventStart":1487,"domContentLoadedEventEnd":1522,"domComplete":2368,"loadEventStart":2368,"loadEventEnd":2370,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":1421.0999999046326},{"name":"bigPipe.sidebar-id.end","time":1421.7999997138977},{"name":"bigPipe.activity-panel-pipe-id.start","time":1421.8999996185303},{"name":"bigPipe.activity-panel-pipe-id.end","time":1424.5},{"name":"activityTabFullyLoaded","time":1528.5999999046326}],"measures":[],"correlationId":"28a0d2e7d2b11d","effectiveType":"4g","downlink":10,"rtt":0,"serverDuration":70,"dbReadsTimeInMs":10,"dbConnsTimeInMs":16,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}