Skip to content

Commit

Permalink
Allow empty lines and comments in peer-fingerprint blocks
Browse files Browse the repository at this point in the history
Signed-off-by: Heiko Hund <heiko@openvpn.net>
  • Loading branch information
d12fk authored and dsommers committed Dec 14, 2022
1 parent d7c16e5 commit 83d5a53
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
11 changes: 10 additions & 1 deletion openvpn/ssl/peer_fingerprint.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,16 @@ struct PeerFingerprints {

opt[i].touch();
while (std::getline(fps, fp))
fingerprints_.emplace_back(PeerFingerprint(fp, fp_size));
{
// Ignore empty lines and comments in fingerprint blocks
std::string trimmed = string::trim_copy(fp);
if (trimmed.empty() ||
string::starts_with(trimmed, "#") ||
string::starts_with(trimmed, ";"))
continue;

fingerprints_.emplace_back(PeerFingerprint(fp, fp_size));
}
}
}

Expand Down
3 changes: 3 additions & 0 deletions test/unittests/test_peer_fingerprint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,11 @@ TEST(PeerFingerprint, parse_config) {
cfg.parse_from_config(
"peer-fingerprint 01:F5:A6:4D:4A:CB:65:E1:8A:9F:55:89:7F:77:A0:79:AA:FB:CC:A1:37:2F:D8:B3:47:AA:9D:E3:D0:76:B1:44\n"
"<peer-fingerprint>\n"
" \n"
"02:F5:A6:4D:4A:CB:65:E1:8A:9F:55:89:7F:77:A0:79:AA:FB:CC:A1:37:2F:D8:B3:47:AA:9D:E3:D0:76:B1:44\n"
"# comment\n"
"03:F5:A6:4D:4A:CB:65:E1:8A:9F:55:89:7F:77:A0:79:AA:FB:CC:A1:37:2F:D8:B3:47:AA:9D:E3:D0:76:B1:44 \n"
" ; comment\n"
"04:F5:A6:4D:4A:CB:65:E1:8A:9F:55:89:7F:77:A0:79:AA:FB:CC:A1:37:2F:D8:B3:47:AA:9D:E3:D0:76:B1:44 \n"
"</peer-fingerprint>\n"
"peer-fingerprint 05:F5:A6:4D:4A:CB:65:E1:8A:9F:55:89:7F:77:A0:79:AA:FB:CC:A1:37:2F:D8:B3:47:AA:9D:E3:D0:76:B1:44 \n"
Expand Down

0 comments on commit 83d5a53

Please sign in to comment.