Skip to content
This repository was archived by the owner on Nov 24, 2025. It is now read-only.

Fix subject name validation in TR certificate loading#4998

Merged
mattjackson220 merged 4 commits intoapache:masterfrom
limited:master-sanfix
Oct 14, 2020
Merged

Fix subject name validation in TR certificate loading#4998
mattjackson220 merged 4 commits intoapache:masterfrom
limited:master-sanfix

Conversation

@limited
Copy link
Contributor

@limited limited commented Aug 28, 2020

What does this PR (Pull Request) do?

When validating the certificate subject name against the sslkeys hostname, TR did not properly parse Subject Alternate Names. Specifically TR assumes all subject names were contained on the Common Name (CN) line and attempted to strip off the remainder of subject before removing the wildcard.

On subject alternate names, there is no CN= delimiter and the wildcard removal was failing.

  • This PR is not related to any Issue

Which Traffic Control components are affected by this PR?

  • Traffic Router
  • NO Docs (just a bugfix)

What is the best way to verify this PR?

  • Run automated unit tests, specifically CertificateDataConverterTest

The following criteria are ALL met by this PR

  • This PR includes tests
  • I have explained why documentation is unnecessary
  • This PR includes an update to CHANGELOG.md
  • This PR includes any and all required license headers
  • This PR does not include a database migration
  • This PR DOES NOT FIX A SERIOUS SECURITY VULNERABILITY (see the Apache Software Foundation's security guidelines for details)

  When validating the certificate subject name against the sslkeys
hostname, TR did not properly parse Subject Alternate Names. Specifically
TR assumes all subject names were contained on the Common Name (CN) line
and attempted to strip off the remainder of subject before removing the wildcard.
  On subject alternate names, there is no CN= delimiter and the wildcard
removal was failing.

Solution: Check for presence of CN and other delimiters before attemping
          to remove them.
@limited limited added bug something isn't working as intended Traffic Router related to Traffic Router labels Aug 28, 2020
}

subjectName = subjectName.replaceFirst("\\*\\.", ".");
if (subjectName.length() > 0 && (hostAlias.contains(subjectName) || subject.contains(subjectName))) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this maybe be if (subjectName.length() > 0 && (hostAlias.contains(subjectName) || subjectName.contains(hostAlias))) {? i think subject.contains(subjectName) will always be true

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch. I'll fix this and likely add a test to verify

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@rawlinp
Copy link
Contributor

rawlinp commented Oct 14, 2020

@limited FYI this PR has merge conflicts.

@limited
Copy link
Contributor Author

limited commented Oct 14, 2020

@limited FYI this PR has merge conflicts.

Thanks @rawlinp.

I resolved the CHANGELOG conflict, but it might pop back up again depending on when this actually gets merged.

@mitchell852
Copy link
Member

@limited - sorry, conflict again. :(

@limited
Copy link
Contributor Author

limited commented Oct 14, 2020 via email

Copy link
Contributor

@mattjackson220 mattjackson220 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Tests pass and testing manually looks good!

@mattjackson220 mattjackson220 merged commit 6713c4d into apache:master Oct 14, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

bug something isn't working as intended Traffic Router related to Traffic Router

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants