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

SNIHostName is going to throw an exception when hostname has a trailing dot #656

Closed
wants to merge 3 commits into from

Conversation

seanmcnealy
Copy link
Contributor

…ng dot

Make sure that:

  • You have read the contribution guidelines.
  • You have created a feature request first to discuss your contribution intent. Please reference the feature request ticket number in the pull request.
  • You use the code formatters provided here and have them applied to your changes. Don't submit any formatting related changes.
  • You submit test cases (unit or integration tests) that back your changes.

Issue description

SSL SNI hostname with trailing dot unable to connect

New Public APIs

Additional context

Minor issue, as there is an easy workaround to disable SNI through configuration that avoids the issue entirely. The underlying library throws an error when there is a trailing dot on an SNI hostname. Looks easy enough to match that library's validation in the SSLConfig validation.

@mp911de
Copy link
Collaborator

mp911de commented Jun 6, 2024

How come that a host name returned from InetSocketAddress ends with a dot?

@seanmcnealy
Copy link
Contributor Author

Looks like some DNS clients support adding a trailing dot which signifies to not use a search domain when resolving a name. I'm not an expert on this, I just have a coworker who used this convention when setting some environment variables.

I've tested 1.0.4 (works) and 1.0.5 (throws validation exception) with the following code:

import io.r2dbc.postgresql.PostgresqlConnectionConfiguration
import io.r2dbc.postgresql.PostgresqlConnectionFactory
import io.r2dbc.postgresql.client.SSLMode

val config =
    PostgresqlConnectionConfiguration.builder()
        .host("database.internal.")
        .port(5432)
        .database("reporting")
        .username("user")
        .password("xxxx")
        .sslMode(SSLMode.REQUIRE)
        .build()
val factory = PostgresqlConnectionFactory(config)

factory.create().block()

I could also see trimming trailing dots before sending to the SNIHostName constructor as valid. That would support SNI better, I think. Unless changing hostnames at all can cause more surprising results.

mp911de pushed a commit that referenced this pull request Oct 2, 2024
mp911de added a commit that referenced this pull request Oct 2, 2024
Reformat code. Split tests into positives and negatives.

[#656]
@mp911de mp911de closed this in 26844d3 Oct 2, 2024
mp911de added a commit that referenced this pull request Oct 2, 2024
Reformat code. Split tests into positives and negatives.

[#656]
@mp911de mp911de added this to the 1.0.6.RELEASE milestone Oct 2, 2024
@mp911de mp911de added the type: bug A general bug label Oct 2, 2024
@mp911de
Copy link
Collaborator

mp911de commented Oct 2, 2024

Thank you for your contribution. That's merged, polished, and backported now.

@mp911de mp911de linked an issue Oct 2, 2024 that may be closed by this pull request
@mp911de mp911de changed the title #653 SNIHostName is going to throw an exception when hostname has a traili… SNIHostName is going to throw an exception when hostname has a trailing dot Oct 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SSL SNI hostname with trailing dot unable to connect
2 participants