Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

security: Allow empty security config for disabling tls #9234

Merged
merged 9 commits into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions dbms/src/Common/TiFlashSecurity.h
Original file line number Diff line number Diff line change
Expand Up @@ -272,18 +272,18 @@ class TiFlashSecurityConfig : public ConfigObject
String new_key_path;
if (config.has("security.ca_path"))
{
new_ca_path = config.getString("security.ca_path");
miss_ca_path = false;
new_ca_path = Poco::trim(config.getString("security.ca_path"));
miss_ca_path = new_ca_path.empty();
}
if (config.has("security.cert_path"))
{
new_cert_path = config.getString("security.cert_path");
miss_cert_path = false;
new_cert_path = Poco::trim(config.getString("security.cert_path"));
miss_cert_path = new_cert_path.empty();
}
if (config.has("security.key_path"))
{
new_key_path = config.getString("security.key_path");
miss_key_path = false;
new_key_path = Poco::trim(config.getString("security.key_path"));
miss_key_path = new_key_path.empty();
JaySon-Huang marked this conversation as resolved.
Show resolved Hide resolved
}

if (miss_ca_path && miss_cert_path && miss_key_path)
Expand Down
18 changes: 18 additions & 0 deletions dbms/src/Common/tests/gtest_tiflash_security.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,24 @@ cert_allowed_cn="tidb"
ASSERT_EQ((int)new_tiflash_config.allowedCommonNames().count("tidb"), 0);
}

TEST(TiFlashSecurityTest, EmptyConfig)
{
TiFlashSecurityConfig tiflash_config;
const auto log = Logger::get();
tiflash_config.setLog(log);

String test =
R"(
[security]
ca_path=" "
cert_path=""
key_path=""
)";
auto new_config = loadConfigFromString(test);
tiflash_config.update(*new_config);
ASSERT_FALSE(tiflash_config.hasTlsConfig());
}

TEST(TiFlashSecurityTest, RedactLogConfig)
{
for (const auto & [input, expect] : std::vector<std::pair<String, RedactMode>>{
Expand Down
8 changes: 4 additions & 4 deletions dbms/src/Storages/DeltaMerge/DeltaTree.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,8 @@ struct DTLeaf

static inline bool overflow(size_t count) { return count > M * S; }
static inline bool underflow(size_t count) { return count < M; }
inline bool legal() { return !overflow(count) && !underflow(count); }
JaySon-Huang marked this conversation as resolved.
Show resolved Hide resolved
inline std::string state() { return overflow(count) ? "overflow" : (underflow(count) ? "underflow" : "legal"); }
inline bool legal() const { return !overflow(count) && !underflow(count); }
inline String state() const { return overflow(count) ? "overflow" : (underflow(count) ? "underflow" : "legal"); }
JaySon-Huang marked this conversation as resolved.
Show resolved Hide resolved

/// shift entries from pos with n steps.
inline void shiftEntries(size_t pos, int n)
Expand Down Expand Up @@ -371,8 +371,8 @@ struct DTIntern

static inline bool overflow(size_t count) { return count > F * S; }
static inline bool underflow(size_t count) { return count < F; }
inline bool legal() { return !overflow(count) && !underflow(count); }
inline std::string state() { return overflow(count) ? "overflow" : (underflow(count) ? "underflow" : "legal"); }
inline bool legal() const { return !overflow(count) && !underflow(count); }
inline String state() const { return overflow(count) ? "overflow" : (underflow(count) ? "underflow" : "legal"); }
JaySon-Huang marked this conversation as resolved.
Show resolved Hide resolved

/// shift entries from pos with n steps.
inline void shiftEntries(size_t child_pos, int n)
Expand Down