Skip to content

Commit cca9751

Browse files
Align JS/TS sample SSL configuration
1 parent ef7d810 commit cca9751

10 files changed

Lines changed: 9 additions & 35 deletions

File tree

.github/workflows/typescript-type-orm-integ-tests.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ jobs:
5353
REGION: ${{ secrets.TYPESCRIPT_TYPE_ORM_CLUSTER_REGION }}
5454
run: |
5555
npm install
56-
wget https://www.amazontrust.com/repository/AmazonRootCA1.pem -O root.pem
5756
npm run build
5857
npm run migrations-drop-table
5958
npm run migrations-create-table

javascript/node-postgres/src/index.js

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,15 @@ async function getConnection(clusterEndpoint, user, region) {
2121
signer.user = user;
2222
token = await signer.getDbConnectAuthToken()
2323
}
24-
// <https://node-postgres.com/apis/client>
25-
// By default `rejectUnauthorized` is true in TLS options
26-
// <https://nodejs.org/api/tls.html#tls_tls_connect_options_callback>
27-
// The config does not offer any specific parameter to set sslmode to verify-full
28-
// Settings are controlled either via connection string or by setting
29-
// rejectUnauthorized to false in ssl options
3024
let client = new Client({
3125
host: clusterEndpoint,
3226
user: user,
3327
password: token,
3428
database: "postgres",
3529
port: 5432,
36-
// <https://node-postgres.com/announcements> for version 8.0
37-
ssl: true
30+
ssl: {
31+
rejectUnauthorized: true,
32+
}
3833
});
3934

4035
// Connect

javascript/postgres-js/src/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ async function getConnection(clusterEndpoint, user, region) {
1818
database: "postgres",
1919
port: 5432,
2020
idle_timeout: 2,
21-
ssl: true,
21+
ssl: {
22+
rejectUnauthorized: true,
23+
}
2224
// max: 1, // Optionally set maximum connection pool size
2325
})
2426

typescript/sequelize/README.md

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,6 @@ It should output something similar to `Version 5.6.x` or higher.
5252
[Using database roles with IAM roles](https://docs.aws.amazon.com/aurora-dsql/latest/userguide/using-database-and-iam-roles.html)
5353
guide.
5454

55-
### Download the Amazon root certificate from the official trust store
56-
57-
Download the Amazon root certificate from the official trust store. This example shows one of the available certs that
58-
can be used by the client. Other certs such as AmazonRootCA2.pem, AmazonRootCA3.pem, etc. can also be used.
59-
60-
```
61-
wget https://www.amazontrust.com/repository/AmazonRootCA1.pem -O root.pem
62-
```
63-
6455
### Run the code
6556

6657
The example demonstrates the following operations:

typescript/sequelize/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ async function getSequelizeConnection(): Promise<Sequelize> {
3232
clientMinMessages: 'ignore', // This is essential
3333
skipIndexes: true,
3434
ssl: {
35-
mode: 'verify-full'
36-
},
35+
rejectUnauthorized: true,
36+
}
3737
},
3838
pool: {
3939
max: 5,

typescript/type-orm/README.md

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,6 @@ The code automatically detects the user type and adjusts its behavior accordingl
4343
[Using database roles with IAM roles](https://docs.aws.amazon.com/aurora-dsql/latest/userguide/using-database-and-iam-roles.html)
4444
guide.
4545

46-
### Download the Amazon root certificate from the official trust store
47-
48-
Download the Amazon root certificate from the official trust store. This example shows one of the available certs that
49-
can be used by the client. Other certs such as AmazonRootCA2.pem, AmazonRootCA3.pem, etc. can also be used.
50-
51-
```
52-
wget https://www.amazontrust.com/repository/AmazonRootCA1.pem -O root.pem
53-
```
54-
5546
### Set up environment for examples
5647

5748
```

typescript/type-orm/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99
"migrations-run": "npm run typeorm migration:run -- -d ./dist/src/data-source --transaction none",
1010
"migrations-revert": "npm run typeorm migration:revert -- -d ./dist/src/data-source --transaction none",
1111
"build:compile": "tsc --build",
12-
"build:copy": "mkdir -p dist/src && cp root.pem dist/src",
13-
"build": "npm-run-all build:compile build:copy",
12+
"build": "npm-run-all build:compile",
1413
"clean": "rm -rf build && rm -rf dist",
1514
"typeorm": "ts-node ./node_modules/typeorm/cli.js",
1615
"start": "node dist/index.js",

typescript/type-orm/src/create-migrations-table.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ const createMigrationsTable = async () => {
3333
port: 5432,
3434
database: "postgres",
3535
ssl: {
36-
ca: fs.readFileSync(path.join(__dirname, "root.pem")),
3736
rejectUnauthorized: true,
3837
},
3938
});

typescript/type-orm/src/data-source.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ const getDataSource = async () => {
3333
password: token,
3434
database: "postgres",
3535
ssl: {
36-
ca: fs.readFileSync(path.join(__dirname, "root.pem")),
3736
rejectUnauthorized: true,
3837
},
3938
synchronize: false,

typescript/type-orm/src/drop-migrations-table.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ const dropMigrationsTable = async () => {
3131
port: 5432,
3232
database: "postgres",
3333
ssl: {
34-
ca: fs.readFileSync(path.join(__dirname, "root.pem")),
3534
rejectUnauthorized: true,
3635
},
3736
});

0 commit comments

Comments
 (0)