Skip to content

Commit

Permalink
#26481 include in 23.01.9
Browse files Browse the repository at this point in the history
  • Loading branch information
erickgonzalez committed Nov 20, 2023
1 parent c729238 commit 425493e
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 7 deletions.
14 changes: 13 additions & 1 deletion dotCMS/src/main/java/com/dotcms/dotpubsub/PgNgDataSourceUrl.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
*/
class PgNgDataSourceUrl {

static final String SSL_MODE = System.getenv("DOT_PUBSUB_SSL_MODE") != null ? System.getenv("DOT_PUBSUB_SSL_MODE") : "prefer";

private final String finalUrl;

/**
Expand Down Expand Up @@ -66,7 +68,17 @@ private String createUrl(final String username, final String password, final Str
sw.append("/");
sw.append(data[data.length - 1]);

return sw.toString();
if(url.contains("ssl.mode=")){
return sw.toString();
}
if(url.contains("?")){
sw.append( "&");
}else{
sw.append( "?");
}

sw.append("ssl.mode=" + SSL_MODE);
return sw.toString();

}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.dotcms.dotpubsub;

import java.net.MalformedURLException;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import org.junit.BeforeClass;
Expand All @@ -10,10 +11,7 @@ public class PgNgDataSourceUrlTest {

@BeforeClass
public static void setUpBeforeClass() throws Exception {}



final String PgNgUrl = "jdbc:pgsql://dotcmsUserName:dotcmsPassword@dbServer.com/dotcms";
final String PgNgUrl = "jdbc:pgsql://dotcmsUserName:dotcmsPassword@dbServer.com/dotcms?ssl.mode=" + PgNgDataSourceUrl.SSL_MODE;



Expand Down Expand Up @@ -72,8 +70,25 @@ public void test_PgNgDataSourceUrl_URL_escapes_special_chars() {


}


@Test
public void test_ssl_mode_is_added() throws MalformedURLException {

String url = "jdbc:postgresql://dbServer.com/dotcms";
String username = "username";
String password = "password";


PgNgDataSourceUrl testDataSource = new PgNgDataSourceUrl(username, password, url);

assert testDataSource.getDbUrl().contains("?ssl.mode=" + PgNgDataSourceUrl.SSL_MODE);

url = "jdbc:postgresql://dbServer.com/dotcms?test=here";


testDataSource = new PgNgDataSourceUrl(username, password, url);

assert testDataSource.getDbUrl().contains("&ssl.mode=" + PgNgDataSourceUrl.SSL_MODE);

}
}

1 change: 1 addition & 0 deletions hotfix_tracking.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,3 +170,4 @@ This maintenance release includes the following code fixes:
140. https://github.com/dotCMS/core/issues/24775 : LogViewer connection times out. #24775
141. https://github.com/dotCMS/core/issues/24885 : Define startup and liveness probes #24885
142. https://github.com/dotCMS/core/issues/25613 : MonitorResource throws exception if DOT_SYSTEM_STATUS_API_IP_ACL is not set #25613
143. https://github.com/dotCMS/core/issues/26481 : Pubsub Connection should prefer SSL #26481

0 comments on commit 425493e

Please sign in to comment.