Skip to content

Commit 3e51864

Browse files
author
tvsathvi
committed
Add global-bundle.pem to default cert list
- Removed rds-ca-2019-root.pem as it is included in global-bundle.pem. - This change simplifies the certificate management in the JDBC driver.
1 parent 1ea46ab commit 3e51864

File tree

7 files changed

+3066
-62
lines changed

7 files changed

+3066
-62
lines changed

Diff for: src/main/java/software/amazon/documentdb/jdbc/DocumentDbConnectionProperties.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public class DocumentDbConnectionProperties extends Properties {
6868

6969
private static final Logger LOGGER = LoggerFactory.getLogger(DocumentDbConnectionProperties.class.getName());
7070
private static final Pattern WHITE_SPACE_PATTERN = Pattern.compile("^\\s*$");
71-
private static final String ROOT_2019_PEM_RESOURCE_FILE_NAME = "/rds-ca-2019-root.pem";
71+
private static final String GLOBAL_BUNDLE_PEM_RESOURCE_FILE_NAME = "/global-bundle.pem";
7272
private static final String ROOT_2021_PEM_RESOURCE_FILE_NAME = "/rds-prod-root-ca-2021.pem";
7373
public static final String HOME_PATH_PREFIX_REG_EXPR = "^~[/\\\\].*$";
7474
public static final int FETCH_SIZE_DEFAULT = 2000;
@@ -1431,9 +1431,9 @@ void appendEmbeddedAndOptionalCaCertificates(final List<Certificate> caCertifica
14311431
}
14321432
}
14331433
// Load embedded CA root certificates.
1434-
try (InputStream pem2019ResourceAsStream = getClass().getResourceAsStream(ROOT_2019_PEM_RESOURCE_FILE_NAME);
1434+
try (InputStream globalBundleResourceAsStream = getClass().getResourceAsStream(GLOBAL_BUNDLE_PEM_RESOURCE_FILE_NAME);
14351435
InputStream pem2021ResourceAsStream = getClass().getResourceAsStream(ROOT_2021_PEM_RESOURCE_FILE_NAME)) {
1436-
caCertificates.addAll(CertificateUtils.loadCertificate(pem2019ResourceAsStream));
1436+
caCertificates.addAll(CertificateUtils.loadCertificate(globalBundleResourceAsStream));
14371437
caCertificates.addAll(CertificateUtils.loadCertificate(pem2021ResourceAsStream));
14381438
}
14391439
}

Diff for: src/main/resources/global-bundle.pem

+3,028
Large diffs are not rendered by default.

Diff for: src/main/resources/rds-ca-2019-root.pem

-24
This file was deleted.

Diff for: src/markdown/setup/connection-string.md

+23-23
Large diffs are not rendered by default.

Diff for: src/markdown/setup/setup.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@ If you are connecting to a TLS-enabled cluster, you may want to specify the Amaz
3636
on your connection string. By default, an Amazon RDS Certificate Authority root certificate has been embedded in the
3737
JDBC driver JAR file which should work when connecting to Amazon DocumentDB clusters using SSL/TLS encryption. However,
3838
if you want to provide a new Amazon RDS Certificate Authority root certificate, follow the directions below:
39-
1. [Download the root CA certificate](https://s3.amazonaws.com/rds-downloads/rds-ca-2019-root.pem)
39+
1. [Download the root CA certificate](https://truststore.pki.rds.amazonaws.com/global/global-bundle.pem)
4040
2. It is recommended to relocate the file to your user's home directory: `$HOME` for Windows or `~` for MacOS/Linux.
4141
3. Add the `tlsCAFile` option to your [JDBC connection string](connection-string.md). For example:
4242

4343
~~~
44-
jdbc:documentdb://localhost:27017/<database-name>?tlsAllowInvalidHostnames=true&tlsCAFile=rds-ca-2019-root.pem
44+
jdbc:documentdb://localhost:27017/<database-name>?tlsAllowInvalidHostnames=true&tlsCAFile=global-bundle.pem
4545
~~~
4646
4747
To determine whether your cluster is TLS-enabled, you can

Diff for: src/markdown/support/troubleshooting-guide.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,8 @@ The online security resources may give a pointer how to fix this.
119119
See [Specifying the Amazon RDS Certificate Authority Certificate File](../setup/setup.md#specifying-the-amazon-rds-certificate-authority-certificate-file).
120120
1. Copy the file to your home directory.
121121
1. Provide the root certificate file name in the connection.
122-
- Tableau: *TLS Certificate Authority File (Optional)* : `~/rds-ca-2019-root.pem`
123-
- DbVisualizer: `jdbc:documentdb://localhost:27017/test?tls=true&tlsAllowInvalidHostnames=true&tlsCAFile=~/rds-ca-2019-root.pem`
122+
- Tableau: *TLS Certificate Authority File (Optional)* : `~/global-bundle.pem`
123+
- DbVisualizer: `jdbc:documentdb://localhost:27017/test?tls=true&tlsAllowInvalidHostnames=true&tlsCAFile=~/global-bundle.pem`
124124

125125
### Invalid hostname
126126
#### What to look for:

Diff for: src/test/java/software/amazon/documentdb/jdbc/DocumentDbConnectionPropertiesTest.java

+8-8
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public void testValidProperties() {
6565
properties.setTlsAllowInvalidHostnames("true");
6666
properties.setTlsEnabled("true");
6767
properties.setRetryReadsEnabled("true");
68-
properties.setTlsCAFilePath("src/main/resources/rds-ca-2019-root.pem");
68+
properties.setTlsCAFilePath("src/main/resources/global-bundle.pem");
6969
properties.setSshUser("SSHUSER");
7070
properties.setSshHostname("SSHHOST");
7171
properties.setSshPrivateKeyFile("~/.ssh/test-file-name.pem");
@@ -89,7 +89,7 @@ public void testValidProperties() {
8989
Assertions.assertTrue(properties.getTlsEnabled());
9090
Assertions.assertTrue(properties.getTlsAllowInvalidHostnames());
9191
Assertions.assertTrue(properties.getRetryReadsEnabled());
92-
Assertions.assertEquals("src/main/resources/rds-ca-2019-root.pem",
92+
Assertions.assertEquals("src/main/resources/global-bundle.pem",
9393
properties.getTlsCAFilePath());
9494
Assertions.assertEquals("SSHUSER", properties.getSshUser());
9595
Assertions.assertEquals("SSHHOST", properties.getSshHostname());
@@ -109,7 +109,7 @@ public void testValidProperties() {
109109
+ "&scanLimit=100"
110110
+ "&replicaSet=rs0"
111111
+ "&tlsAllowInvalidHostnames=true"
112-
+ "&tlsCAFile=src%2Fmain%2Fresources%2Frds-ca-2019-root.pem"
112+
+ "&tlsCAFile=src%2Fmain%2Fresources%2Fglobal-bundle.pem"
113113
+ "&sshUser=SSHUSER"
114114
+ "&sshHost=SSHHOST"
115115
+ "&sshPrivateKeyFile=%7E%2F.ssh%2Ftest-file-name.pem"
@@ -241,7 +241,7 @@ public void testSetPropertiesFromConnectionString() throws SQLException {
241241
"&" + DocumentDbConnectionProperty.REPLICA_SET.getName() + "=" + "rs0" +
242242
"&" + DocumentDbConnectionProperty.TLS_ENABLED.getName() + "=" + "true" +
243243
"&" + DocumentDbConnectionProperty.TLS_ALLOW_INVALID_HOSTNAMES.getName() + "=" + "true" +
244-
"&" + DocumentDbConnectionProperty.TLS_CA_FILE.getName() + "=" + "~/rds-ca-2019-root.pem" +
244+
"&" + DocumentDbConnectionProperty.TLS_CA_FILE.getName() + "=" + "~/global-bundle.pem" +
245245
"&" + DocumentDbConnectionProperty.LOGIN_TIMEOUT_SEC.getName() + "=" + "4" +
246246
"&" + DocumentDbConnectionProperty.RETRY_READS_ENABLED.getName() + "=" + "true" +
247247
"&" + DocumentDbConnectionProperty.METADATA_SCAN_METHOD.getName() + "=" + "random" +
@@ -419,11 +419,11 @@ void testAppendEmbeddedAndOptionalCaCertificates() throws SQLException, IOExcept
419419
.getPropertiesFromConnectionString(info, connectionString, DOCUMENT_DB_SCHEME);
420420
final List<Certificate> caCertificates = new ArrayList<>();
421421
properties.appendEmbeddedAndOptionalCaCertificates(caCertificates);
422-
Assertions.assertEquals(2, caCertificates.size());
422+
Assertions.assertEquals(122, caCertificates.size());
423423
caCertificates.clear();
424-
properties.setTlsCAFilePath("src/main/resources/rds-ca-2019-root.pem");
424+
properties.setTlsCAFilePath("src/main/resources/global-bundle.pem");
425425
properties.appendEmbeddedAndOptionalCaCertificates(caCertificates);
426-
Assertions.assertEquals(3, caCertificates.size());
426+
Assertions.assertEquals(243, caCertificates.size());
427427
caCertificates.clear();
428428
properties.setTlsCAFilePath("invalid-path.pem");
429429
Assertions.assertThrows(SQLException.class,
@@ -447,7 +447,7 @@ void testBuildSshConnectionProperties() throws SQLException {
447447
properties.setTlsAllowInvalidHostnames("true");
448448
properties.setTlsEnabled("true");
449449
properties.setRetryReadsEnabled("true");
450-
properties.setTlsCAFilePath("src/main/resources/rds-ca-2019-root.pem");
450+
properties.setTlsCAFilePath("src/main/resources/global-bundle.pem");
451451
properties.setSshUser("SSHUSER");
452452
properties.setSshHostname("SSHHOST");
453453
properties.setSshPrivateKeyFile("~/.ssh/test-file-name.pem");

0 commit comments

Comments
 (0)