Skip to content

Commit

Permalink
Extend SNIHostName check to reject hostnames with trailing dot.
Browse files Browse the repository at this point in the history
[resolves #656]
  • Loading branch information
seanmcnealy authored and mp911de committed Oct 2, 2024
1 parent 52a54b9 commit f08ac1c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/main/java/io/r2dbc/postgresql/client/SSLConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public static boolean isValidSniHostname(String input) {
return false;
}
}
return true;
return !input.endsWith(".");
}

//
Expand Down
17 changes: 17 additions & 0 deletions src/test/java/io/r2dbc/postgresql/client/SSLConfigTests.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package io.r2dbc.postgresql.client;

import org.junit.jupiter.api.Test;

import static org.assertj.core.api.Assertions.assertThat;

/**
* Unit tests for {@link SSLConfig}.
*/
final class SSLConfigTests {
@Test
public void testValidSniHostname(){
assertThat(SSLConfig.isValidSniHostname("example.com")).isEqualTo(true);
assertThat(SSLConfig.isValidSniHostname("example://.com")).isEqualTo(false);
assertThat(SSLConfig.isValidSniHostname("example.com.")).isEqualTo(false);
}
}

0 comments on commit f08ac1c

Please sign in to comment.