Skip to content

Commit

Permalink
Fix unable to parse SSL version (#2981)
Browse files Browse the repository at this point in the history
* On some systems OpenSSL version cannot be parsed. When this cannot be parsed, do not force exit, allow the client to continue operations. If the OpenSSL version string is not empty, display the unparsable string when using --verbose for future debugging if required.
  • Loading branch information
abraunegg authored Nov 16, 2024
1 parent 22695de commit d956318
Showing 1 changed file with 23 additions and 23 deletions.
46 changes: 23 additions & 23 deletions src/util.d
Original file line number Diff line number Diff line change
Expand Up @@ -1446,31 +1446,31 @@ void checkOpenSSLVersion() {

auto matches = versionString.match(versionRegex);
if (matches.empty) {
addLogEntry("Unable to parse OpenSSL version.");
// Must force exit here, allow logging to be done
forceExit();
}

// Extract major, minor, patch, and optional letter parts
uint major = matches.captures[1].to!uint;
uint minor = matches.captures[2].to!uint;
uint patch = matches.captures[3].to!uint;
string letter = matches.captures[4]; // Empty if version is 3.x.x or higher
string distributionWarning = " Please report this to your distribution, requesting an update to a newer OpenSSL version, or consider upgrading it yourself for optimal stability.";

// Compare versions
if (major < 1 || (major == 1 && minor < 1) || (major == 1 && minor == 1 && patch < 1) ||
(major == 1 && minor == 1 && patch == 1 && (letter.empty || letter[0] < 'a'))) {
if (!versionString.empty) {
if (verboseLogging) {addLogEntry("Unable to provided parse OpenSSL version: " ~ versionString, ["verbose"]);}
}
} else {
// Extract major, minor, patch, and optional letter parts
uint major = matches.captures[1].to!uint;
uint minor = matches.captures[2].to!uint;
uint patch = matches.captures[3].to!uint;
string letter = matches.captures[4]; // Empty if version is 3.x.x or higher
string distributionWarning = " Please report this to your distribution, requesting an update to a newer OpenSSL version, or consider upgrading it yourself for optimal stability.";

// Compare versions
if (major < 1 || (major == 1 && minor < 1) || (major == 1 && minor == 1 && patch < 1) ||
(major == 1 && minor == 1 && patch == 1 && (letter.empty || letter[0] < 'a'))) {
addLogEntry();
addLogEntry(format("WARNING: Your OpenSSL version (%d.%d.%d%s) is below the minimum required version of 1.1.1a. Significant operational issues are likely when using this client.", major, minor, patch, letter), ["info", "notify"]);
addLogEntry(distributionWarning);
addLogEntry();
} else if (major == 1 && minor == 1 && patch == 1 && !letter.empty && letter[0] >= 'a' && letter[0] <= 'w') {
addLogEntry();
addLogEntry(format("WARNING: Your OpenSSL version (%d.%d.%d%s) is below the minimum required version of 1.1.1a. Significant operational issues are likely when using this client.", major, minor, patch, letter), ["info", "notify"]);
addLogEntry(format("WARNING: Your OpenSSL version (%d.%d.%d%s) may cause stability issues with this client.", major, minor, patch, letter), ["info", "notify"]);
addLogEntry(distributionWarning);
addLogEntry();
} else if (major == 1 && minor == 1 && patch == 1 && !letter.empty && letter[0] >= 'a' && letter[0] <= 'w') {
addLogEntry();
addLogEntry(format("WARNING: Your OpenSSL version (%d.%d.%d%s) may cause stability issues with this client.", major, minor, patch, letter), ["info", "notify"]);
addLogEntry(distributionWarning);
addLogEntry();
} else if (major >= 3) {
// Do nothing for version >= 3.0.0
} else if (major >= 3) {
// Do nothing for version >= 3.0.0
}
}
}

0 comments on commit d956318

Please sign in to comment.