Skip to content

When creating custom TLS certs, add IPs to SANs as IPs and not DNS names#2457

Merged
jhiemstrawisc merged 2 commits into
PelicanPlatform:mainfrom
jhiemstrawisc:issue-2456
Jul 3, 2025
Merged

When creating custom TLS certs, add IPs to SANs as IPs and not DNS names#2457
jhiemstrawisc merged 2 commits into
PelicanPlatform:mainfrom
jhiemstrawisc:issue-2456

Conversation

@jhiemstrawisc

Copy link
Copy Markdown
Member

The issue being fixed here is that some of our internal tests were producing bad certificates by adding IP addresses as DNS names, which was exposed recently when we started checking the configured certs against the configured server hostnames

This diff does two things -- it only toggles the cert<-->hostname validation when TLS is enabled in Pelican, and it adds the IP addresses to the cert correctly regardless.

Some tests use IP addresses from http test servers for various
Pelican server configs (e.g. 'Server.ExternalWebUrl'). When we do
this, the certificates Pelican generates for itself are invalid because
they contain a SAN that says the IP is a DNS entry.

This was exposed in tests for PelicanPlatform#2035 after it picked up the new
verification code that checks the cert against configured hostnames.
@jhiemstrawisc jhiemstrawisc added this to the v7.18 milestone Jun 27, 2025
@jhiemstrawisc jhiemstrawisc added bug Something isn't working test Improvements to the test suite internal Internal code improvements, not user-facing labels Jun 27, 2025
@jhiemstrawisc

Copy link
Copy Markdown
Member Author

@matyasselmeci I'm adding you as a co-reviewer because I'd like someone with a bit more TLS cert knowledge than I have to double check that what I'm saying is correct.

@h2zh h2zh self-assigned this Jun 30, 2025

@h2zh h2zh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM. Like those concise comments! Btw, skipping TLS certificate hostname verification when TLSSkipVerify is true was discussed offline.

P.S. TestStatMemory seems to fail in all open PRs at the moment.

@bbockelm

bbockelm commented Jul 3, 2025

Copy link
Copy Markdown
Collaborator

@jhiemstrawisc - did you catch which tests are using IP addresses? That seems to be the underlying problem here -- we should always use names.

@jhiemstrawisc

Copy link
Copy Markdown
Member Author

Indeed -- the offending test comes from using an httptest server for Pelican config:

viper.Set("Server.ExternalWebUrl", server.URL)

@jhiemstrawisc

Copy link
Copy Markdown
Member Author

@bbockelm Since fixing these underlying tests can be done in a subsequent PR, and since I believe this PR does fix an issue even if it's not the root issue, I'm going to merge. In the short term this unblocks #2035.

@jhiemstrawisc jhiemstrawisc merged commit 3c4d54f into PelicanPlatform:main Jul 3, 2025
27 of 34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working internal Internal code improvements, not user-facing test Improvements to the test suite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pelican's self-generated certs don't handle "IP hostnames" correctly

3 participants