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

update extract CN logic to handle entry with CN in any order #1368

Merged
merged 1 commit into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public final class TlsClientX509ExtendedKeyManager extends X509ExtendedKeyManage
{
public static final String COMMON_NAME_KEY = "common.name";

private static final Pattern COMMON_NAME_PATTERN = Pattern.compile("CN=(?<cn>[^\\s,]+).*");
private static final Pattern COMMON_NAME_PATTERN = Pattern.compile("CN=(?<cn>[^\\s,]+)");

private final Matcher matchCN = COMMON_NAME_PATTERN.matcher("");

Expand Down Expand Up @@ -116,7 +116,7 @@ else if (keyTypes != null)
X500Principal subject = chain[0].getSubjectX500Principal();

if (subject != null &&
matchCN.reset(subject.getName()).matches() &&
matchCN.reset(subject.getName()).find() &&
subjectCN.equals(matchCN.group("cn")))
{
alias = candidate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public final class TlsServerFactory implements TlsStreamFactory
private final TlsServerDecoder decodeNotHandshakingUnwrapped = this::decodeNotHandshakingUnwrapped;
private final TlsServerDecoder decodeIgnoreAll = this::decodeIgnoreAll;

private final Matcher matchCN = Pattern.compile("CN=([^,]*).*").matcher("");
private final Matcher matchCN = Pattern.compile("CN=([^,]*)").matcher("");

private final int proxyTypeId;
private final Signaler signaler;
Expand Down Expand Up @@ -2422,7 +2422,7 @@ private String getCommonName(
if (peer != null)
{
String name = peer.getName();
if (matchCN.reset(name).matches())
if (matchCN.reset(name).find())
{
commonName = matchCN.group(1);
}
Expand Down
Loading