Skip to content

Commit fca7f5f

Browse files
authored
Merge pull request #571 from aws/add-global-cert
Add global-bundle.pem to default cert list and Implement Dynamic .taco Filename Handling
2 parents 1ea46ab + 6d848e5 commit fca7f5f

File tree

10 files changed

+3105
-70
lines changed

10 files changed

+3105
-70
lines changed

.github/workflows/gradle.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ jobs:
196196
MINOR_VERSION=$(grep "MINOR_VERSION" ${file} | cut -d'=' -f2)
197197
PATCH_VERSION=$(grep "PATCH_VERSION" ${file} | cut -d'=' -f2)
198198
echo "version=$MAJOR_VERSION.$MINOR_VERSION.$PATCH_VERSION" >> $GITHUB_ENV
199-
mv tableau-connector/target/documentdbjdbc.taco tableau-connector/target/documentdbjdbc-$MAJOR_VERSION.$MINOR_VERSION.$PATCH_VERSION.taco
199+
mv tableau-connector/target/*.taco tableau-connector/target/documentdbjdbc-$MAJOR_VERSION.$MINOR_VERSION.$PATCH_VERSION.taco
200200
201201
- name: "Configure AWS credentials"
202202
if: ${{env.SIGNING_ENABLED == 'true'}}

src/main/java/software/amazon/documentdb/jdbc/DocumentDbConnectionProperties.java

Lines changed: 3 additions & 3 deletions
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
}

src/main/resources/global-bundle.pem

Lines changed: 3028 additions & 0 deletions
Large diffs are not rendered by default.

src/main/resources/rds-ca-2019-root.pem

Lines changed: 0 additions & 24 deletions
This file was deleted.

src/markdown/setup/connection-string.md

Lines changed: 23 additions & 23 deletions
Large diffs are not rendered by default.

src/markdown/setup/setup.md

Lines changed: 2 additions & 2 deletions
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

src/markdown/support/troubleshooting-guide.md

Lines changed: 2 additions & 2 deletions
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:

src/test/java/software/amazon/documentdb/jdbc/DocumentDbConnectionPropertiesTest.java

Lines changed: 8 additions & 8 deletions
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");

tableau-connector/Dockerfile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@ WORKDIR /tableau-connector
44
ADD ./src .
55
WORKDIR /tableau-sdk
66
RUN git clone https://github.com/tableau/connector-plugin-sdk.git &&\
7-
cd ./connector-plugin-sdk/connector-packager &&\
7+
cd ./connector-plugin-sdk &&\
8+
git checkout tags/tdvt-2.13.7 &&\
9+
cd connector-packager &&\
810
python3 -m venv .venv &&\
911
source ./.venv/bin/activate &&\
1012
python3 setup.py install &&\
1113
python3 -m connector_packager.package /tableau-connector
12-
ENTRYPOINT ["bash"]
14+
ENTRYPOINT ["bash"]

tableau-connector/build.sh

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,49 @@ echo "CURRENT_FOLDER=${CURRENT_FOLDER}"
1212
TARGET_FOLDER="$CURRENT_FOLDER"/target
1313
echo TARGET_FOLDER=${TARGET_FOLDER}
1414
mkdir -p $TARGET_FOLDER
15-
15+
echo "Created directory at: $TARGET_FOLDER"
1616
echo "Building Docker Image"
1717
docker build -t taco-builder $CURRENT_FOLDER
1818

1919
echo "Assembling Tableau Connector"
2020
docker run -d -it --name=taco-builder --mount type=bind,source=$TARGET_FOLDER,target=/output taco-builder
21-
echo "Copying Tableau Connector"
22-
docker exec taco-builder sh -c "cp /tableau-sdk/connector-plugin-sdk/connector-packager/packaged-connector/documentdbjdbc.taco /output"
21+
if [ $? -ne 0 ]; then
22+
echo "Failed to run Docker container."
23+
exit 1
24+
fi
25+
26+
# Dynamically find the taco file to copy. Only one .taco file exists.
27+
echo "Copying Tableau Connector to output directory"
28+
docker exec taco-builder sh -c 'cp /tableau-sdk/connector-plugin-sdk/connector-packager/packaged-connector/*.taco /output/'
29+
if [ $? -ne 0 ]; then
30+
echo "Failed to copy .taco file to /output directory."
31+
exit 1
32+
fi
33+
34+
# Verify the Tableau Connector in the output directory
2335
echo "Verifying Tableau Connector"
2436
docker exec taco-builder sh -c "ls -l /output"
2537
docker exec taco-builder pwd
26-
echo "Extracting Tableau Connector"
27-
docker cp taco-builder:/output/documentdbjdbc.taco $TARGET_FOLDER
38+
echo "Extracting Tableau Connector to $TARGET_FOLDER"
39+
TACO_FILE_NAME=$(docker exec taco-builder sh -c "ls /output/*.taco")
40+
docker cp "taco-builder:$TACO_FILE_NAME" "$TARGET_FOLDER"
41+
if [ $? -ne 0 ]; then
42+
echo "Failed to copy .taco file from Docker container to target folder."
43+
exit 1
44+
fi
45+
echo "Connector extracted to $TARGET_FOLDER/"
2846
echo "Checking Resulting TACO FILE in $TARGET_FOLDER"
2947
ls -l $TARGET_FOLDER
48+
if [ $? -ne 0 ]; then
49+
echo "Failed to list contents of $TARGET_FOLDER."
50+
exit 1
51+
fi
52+
# Stop and remove Docker container
53+
echo "Stopping and removing Docker container"
3054
docker stop taco-builder
3155
docker rm taco-builder
56+
if [ $? -ne 0 ]; then
57+
echo "Failed to stop or remove Docker container."
58+
exit 1
59+
fi
60+
echo "Build process completed successfully."

0 commit comments

Comments
 (0)