我正在尝试使用禁用SSL的TypeORM通过Node API连接到MySQL数据库。我使用MySQL2作为连接数据库的客户端。
我使用不同的连接选项对ormconfig进行了许多更改,但没有一个成功。
ormconfig.ts
// import {
// SSL_OP_NO_SSLv2,
// SSL_OP_NO_SSLv3,
// SSL_OP_NO_TLSv1,
// SSL_OP_NO_TLSv1_1,
// SSL_OP_NO_TLSv1_2
// } from "constants";
import { ConnectionOptions } from "typeorm";
export function getConfig() {
const isTest = process.env.NODE_ENV === "test";
// const secureOptionsBitMask: number =
// SSL_OP_NO_SSLv2 |
// SSL_OP_NO_SSLv3 |
// SSL_OP_NO_TLSv1 |
// SSL_OP_NO_TLSv1_1 |
// SSL_OP_NO_TLSv1_2;
return {
autoSchemaSync: false,
database: DB_NAME,
entities: DB_ENTITIES,
host: DB_HOST,
logging: "all",
migrations: "./test/*-migration.ts",
migrationsRun: isTest,
password: DB_PASS,
port: DB_PORT,
ssl: {},
synchronize: false,
type: DB_TYPE,
username: DB_USER
} as ConnectionOptions;
}
server.js
import { Connection, createConnection } from 'typeorm';
import { getConfig } from '../../ormconfig';
let dbConnection: Connection;
...
dbConnection = await createConnection(getConfig());
...