Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

LB4 with [email protected] causing SSL Error

未关闭
#476 4 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
25/100
Issue 类型
缺陷
描述清晰度
需要澄清
活跃度
停滞
技术栈
javascript, nodejs, postgresql
领域
backend, databases

调研方向

从粘贴的 ProductSelectionApplication 构造函数和使用 [email protected] 的 datasource 配置开始。在与本地环境进行比较的同时,复现 IBM Cloud Kubernetes 部署中的 SSL 失败,然后检查 connector 对 PostgreSQL 和 SSL 的处理。完成的标准是确定原因,并通过有文档记录且经过测试的配置或 connector 修复解决 certificate-chain 错误。

由索引模型根据 Issue 内容生成。

描述

I kept getting the same error in LB4 even using the right syntax below and right version of [email protected] after I deploy it to IBM Cloud Kubenetes, it runs without any issues on my local.

import {BootMixin} from '@loopback/boot';
import {ApplicationConfig} from '@loopback/core';
import {RepositoryMixin} from '@loopback/repository';
import {RestApplication} from '@loopback/rest';
import {
RestExplorerBindings,
RestExplorerComponent
} from '@loopback/rest-explorer';
import {ServiceMixin} from '@loopback/service-proxy';
import fs from 'fs';
import path from 'path';
import {ProductSelectionDataSource} from './datasources';
import {MySequence} from './sequence';
export {ApplicationConfig};

export class ProductSelectionApplication extends BootMixin(
ServiceMixin(RepositoryMixin(RestApplication)),
) {
constructor(options: ApplicationConfig = {}) {
super(options);

//process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = '0';
console.log("__dirname: " + __dirname);
console.log("*********************************************************************************");
const crtpath = path.join(__dirname, '../private/ca.crt');
console.log("crtpath:" + crtpath);
console.log("content of crt:  " + fs.readFileSync(crtpath).toString());

console.log("*********************************************************************************");
const keypath = path.join(__dirname, '../private/ca.key');
console.log("keypath:" + keypath);
console.log("content of key:  " + fs.readFileSync(keypath).toString());

console.log("*********************************************************************************");
var dbcert = process.env.DB_CERT;
let dbCert = Buffer.from(`{dbcert}`, 'base64');
console.log("content of dbcert: " + dbCert);

console.log("*********************************************************************************");

this.bind('datasources.config.productSelection').to({
  name: 'dbname',
  connector: 'postgresql',
  url: process.env.DB_CONNECTION_STRING,
  ssl: {
    ca: fs.readFileSync(crtpath).toString(),
    key: fs.readFileSync(keypath).toString(),
    cert: dbCert,
    rejectUnauthorized: false,
  },
});
this.bind('datasources.productSelection').toClass(ProductSelectionDataSource);

// Set up the custom sequence
this.sequence(MySequence);

// Set up default home page
this.static('/', path.join(__dirname, '../public'));

// Customize @loopback/rest-explorer configuration here
this.configure(RestExplorerBindings.COMPONENT).to({
  path: '/explorer',
});
this.component(RestExplorerComponent);

this.projectRoot = __dirname;
// Customize @loopback/boot Booter Conventions here
this.bootOptions = {
  controllers: {
    // Customize ControllerBooter Conventions here
    dirs: ['controllers'],
    extensions: ['.controller.js'],
    nested: true,
  },
};

}
}

The error I got:

Node ENV: dev
Server is running at http://127.0.0.1:3000
Try http://127.0.0.1:3000/ping
Connection fails: Error: self signed certificate in certificate chain
It will be retried for the next request.
_tls_wrap.js:1497

Error: self signed certificate in certificate chain
at TLSSocket.onConnectSecure (_tls_wrap.js:1497:34)
at TLSSocket.emit (events.js:315:20)
at TLSSocket._finishInit (_tls_wrap.js:932:8)
at TLSWrap.ssl.onhandshakedone (_tls_wrap.js:706:12)
at TLSWrap.callbackTrampoline (internal/async_hooks.js:131:14)

I tried to use old version of [email protected] but it seems the latest version of LB4 doesn't like it. the LB4 version list below:
$ lb4 -v
@loopback/cli version: 2.20.0

@loopback/* dependencies:

  • @loopback/authentication: ^7.1.0
  • @loopback/boot: ^3.3.0
  • @loopback/build: ^6.3.0
  • @loopback/context: ^3.15.0
  • @loopback/core: ^2.15.0
  • @loopback/metadata: ^3.2.0
  • @loopback/openapi-spec-builder: ^3.1.0
  • @loopback/openapi-v3: ^5.2.0
  • @loopback/repository-json-schema: ^3.3.0
  • @loopback/repository: ^3.5.0
  • @loopback/rest: ^9.2.0
  • @loopback/testlab: ^3.3.0
  • @loopback/docs: ^3.23.0
  • @loopback/example-hello-world: ^2.2.0
  • @loopback/example-log-extension: ^2.2.0
  • @loopback/example-rpc-server: ^2.2.0
  • @loopback/example-todo: ^3.10.0
  • @loopback/example-soap-calculator: ^2.5.0
  • @loopback/service-proxy: ^3.1.0
  • @loopback/http-caching-proxy: ^2.2.0
  • @loopback/http-server: ^2.4.0
  • @loopback/example-todo-list: ^3.8.0
  • @loopback/dist-util: ^0.4.0
  • @loopback/rest-explorer: ^3.2.0
  • @loopback/eslint-config: ^10.1.0
  • @loopback/example-express-composition: ^2.6.0
  • @loopback/example-greeter-extension: ^2.2.0
  • @loopback/booter-lb3app: ^2.3.0
  • @loopback/example-lb3-application: ^2.6.0
  • @loopback/example-greeting-app: ^2.3.0
  • @loopback/example-context: ^2.2.0
  • @loopback/repository-tests: ^0.17.0
  • @loopback/health: ^0.7.0
  • @loopback/authorization: ^0.8.0
  • @loopback/rest-crud: ^0.9.0
  • @loopback/security: ^0.4.0
  • @loopback/authentication-passport: ^3.1.0
  • @loopback/example-metrics-prometheus: ^0.5.0
  • @loopback/metrics: ^0.7.0
  • @loopback/model-api-builder: ^2.2.0
  • @loopback/logging: ^0.5.0
  • @loopback/example-access-control-migration: ^2.4.0
  • @loopback/example-file-transfer: ^1.6.0
  • @loopback/example-rest-crud: ^1.8.0
  • @loopback/apiconnect: ^0.6.0
  • @loopback/example-validation-app: ^1.9.0
  • @loopback/cron: ^0.4.0
  • @loopback/example-multi-tenancy: ^0.8.0
  • @loopback/example-passport-login: ^1.10.0
  • @loopback/authentication-jwt: ^0.8.0
  • @loopback/context-explorer: ^0.4.0
  • @loopback/express: ^3.2.0
  • @loopback/example-todo-jwt: ^1.5.0
  • @loopback/mock-oauth2-provider: ^0.2.0
  • @loopback/pooling: ^0.4.0
  • @loopback/typeorm: ^0.3.0
  • @loopback/example-graphql: ^0.2.0
  • @loopback/graphql: ^0.3.0
  • @loopback/filter: ^1.4.0
  • @loopback/rest-msgpack: ^0.4.0
  • @loopback/example-binding-resolution: ^0.2.0
  • @loopback/example-webpack: ^0.3.0
  • @loopback/example-socketio: ^0.2.0
  • @loopback/socketio: ^0.2.0
  • @loopback/monorepo: ^0.2.0
  • @loopback/tsdocs: ^2.5.0

Please advise and thank you so much.

主要语言
JavaScript
星标
118
派生
183
平均合并
3 天 7 小时
30 天内合并 PR
9

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

loopbackio/loopback-connector-postgresql 的其他 Issue

查看 loopbackio/loopback-connector-postgresql 的全部 Issue

相似的 Issue

更多 JavaScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。