-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SSL mode query param (e.g., '?sslmode=required') breaks URI parsing #6544
Comments
Do you have the full URL you're passing? |
@imnotjames here's an obfuscated version, hopefully that's helpful: In case it's helpful, the exact string length on the non-obfuscated one is Here's what I use in my app to correct for it (which is nasty, but it is what it is haha): const vcapPostgres = vcapServices['databases-for-postgresql']?.[0]?.credentials?.connection?.postgres;
const url = vcapPostgres?.composed[0]?.replace('?sslmode=verify-full', '') as string;
const cert = vcapPostgres ? Base64.decode(vcapPostgres.certificate?.certificate_base64) : null;
const connectionOptions = {
url,
type: 'postgres',
entities: [path.join(__dirname, 'entities/*')],
migrations: [path.join(__dirname, 'migration/*')],
migrationsRun: true,
ssl: {
ca: cert,
},
}; |
Ouch! That's not a fun hack to have to implement. I know our URL parsing is all sorts of weird & hope to shore that up sometime in the near future. It doesn't do anything with the query string values but SHOULD remove them from the URLs so the database name doesn't include them. Unfortunately, when testing with 0.2.27 I cannot replicate the issue! Here's the code I ran: import {DriverUtils} from "../../../src/driver/DriverUtils";
import {expect} from "chai";
const DRIVER_URL = 'postgres://XXX_XXXXX_XXXXXXXX_XXXX_XXXX_XXXX_XXXXXXXXXXXX:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX@XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXX.XXXXXXXXXX.databases.appdomain.cloud:31762/XXXclouddb?sslmode=verify-full';
describe('github issues > #6544 SSL mode query param (e.g., \'?sslmode=required\') breaks URI parsing', () => {
it('should correctly parse database from the URI', async () => {
const parameters = DriverUtils.buildDriverOptions({
url: DRIVER_URL
});
expect(parameters.database).to.be.equal('XXXclouddb');
});
}); This bypassed the connection to use the underlying Can you confirm that this is still a problem in 0.2.27? |
If you find that you're still seeing the issue in 0.2.27 please poke back here or in the linked issue. Cheers! |
Issue type:
[ ] question
[x] bug report
[ ] feature request
[ ] documentation issue
Database system/driver:
[ ]
cordova
[ ]
mongodb
[ ]
mssql
[ ]
mysql
/mariadb
[ ]
oracle
[x]
postgres
[ ]
cockroachdb
[ ]
sqlite
[ ]
sqljs
[ ]
react-native
[ ]
expo
TypeORM version:
[x]
latest
[ ]
@next
[ ]
0.x.x
(or put your version here)Steps to reproduce or a small repository showing the problem:
Use a Database URL including
?sslmode=required
and Typeorm will throw an error sayingdatabasename?sslmode=required not found
The text was updated successfully, but these errors were encountered: