Skip to content

Commit acb71c0

Browse files
authored
Make certificate validation comply with RFC2818 (#124)
1 parent 6461410 commit acb71c0

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

trantor/net/inner/TcpConnectionImpl.cc

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,21 +84,30 @@ inline std::string certNameToRegex(const std::string &certName)
8484
result.reserve(certName.size() + 11);
8585

8686
bool isStar = false;
87+
bool isLeadingStar = true;
8788
for (char ch : certName)
8889
{
8990
if (isStar == false)
9091
{
9192
if (ch == '*')
9293
isStar = true;
94+
else if (ch == '.')
95+
{
96+
result += "\\.";
97+
isLeadingStar = false;
98+
}
9399
else
100+
{
94101
result.push_back(ch);
102+
isLeadingStar = false;
103+
}
95104
}
96105
else
97106
{
98-
if (ch == '.')
107+
if (ch == '.' && isLeadingStar)
99108
result += "([^.]*\\.|)?";
100109
else
101-
result += std::string("\\*") + ch;
110+
result += std::string("[^.]*") + ch;
102111
isStar = false;
103112
}
104113
}

0 commit comments

Comments
 (0)