如何解决kubectl-证书错误:错误:0909006C:PEM例程:get_name:无起始行
我每3个月更新一次证书,直到今天我都没问题,但是我不知道为什么:
This error originated either by throwing inside of an async function without a catch block,or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason:
Error: error:0909006C:PEM routines:get_name:no start line
at Object.createSecureContext (_tls_common.js:135:17)
at Server (_tls_wrap.js:903:27)
at new Server (https.js:62:14)
at Object.createServer (https.js:85:10)
at Promise.all.then (/home/graphql/index.js:143:15)
at process._tickCallback (internal/process/next_tick.js:68:7)
我不理解“ PEM例程:get_name:没有起始行”?有人可以帮我吗? 这是我服务器的index.js,已连接到circleCi,并在其中放置了CA_CERT PRIVATE_KEY CERTIFICATE以及与docker的关系
require('dotenv').config();
const express = require('express');
const cors = require('cors');
const https = require('https');
const http = require('http');
const graphqlHTTP = require('express-graphql');
const jwt = require('express-jwt');
const fetch = require('isomorphic-fetch');
const winston = require('winston');
const expressWinston = require('express-winston');
const { v4,v6 } = require('public-ip');
const { makeExecutableSchema } = require('graphql-tools');
// const { SESClient } = require('@aws-sdk/client-ses-node/SESClient');
const AWS = require('aws-sdk');
const Sentry = require('@sentry/node');
const now = require('performance-now');
const typeDefs = require('./schema');
const resolvers = require('./resolvers/index');
// const { getDocuments } = require('./lib/s3');
// const healthCheck = require('./healthCheck');
const mongo = require('./db/mongo');
const { setupPostgres } = require('./db/pg');
const startTime = now();
const {
PORT,NODE_ENV,// AUTH_PUBLIC_KEY,} = process.env;
const debug = process.argv.indexOf('--debug') !== -1;
global.logger = winston.createLogger({
transports: [
new winston.transports.Console({
format: NODE_ENV === 'production' ? winston.format.json() : winston.format.simple(),level: debug ? 'debug' : 'info',}),],});
global.logger.info(`Starting server with args ${JSON.stringify(process.argv.slice(2))}...`);
[v4,v6].map((func) => (func({ https: true })
.then((ip) => { global.logger.info(`External IP ${ip}`); })
.catch(() => {})));
Sentry.init();
AWS.config.update({
region: 'eu-west-1',});
/* global.SES = new SESClient({
region: 'eu-west-1',}); */
const app = express();
const port = PORT || 4000;
const production = NODE_ENV === 'production';
const domainWhitelist = [
'https://platform.fundinginvoice.com','https://platform-devenv.fundinginvoice.com','http://localhost:3000','http://localhost:4000','electron://altair','file://',];
const corsOptions = {
origin(origin,callback) {
if (!origin || domainWhitelist.indexOf(origin) !== -1) {
global.logger.debug(`${origin} allowed by CORS`);
callback(null,true);
} else {
callback(new Error(`${origin} not allowed by CORS`));
}
},};
const executableSchema = makeExecutableSchema({
typeDefs,resolvers,});
mongo.connectLogger();
const AUTH_PUBLIC = 'https://api.fundinginvoice.com/manatee/publickey';
Promise.all([fetch(AUTH_PUBLIC),mongo.connect()])
.then(async ([fetchResponse]) => {
const pgPool = setupPostgres();
const publicKey = await fetchResponse.text();
// getDocuments();
global.logger.info(`Production: ${production}`);
global.logger.info('---- Auth public key ----');
global.logger.info(publicKey);
global.logger.info('---- End auth public key ----');
app.use(
express.json(),cors(corsOptions),expressWinston.logger({
transports: [new winston.transports.Console()],format: winston.format.json(),expressFormat: true,colorize: false,requestWhitelist: ['user','body'],headerBlacklist: ['authorization'],Sentry.Handlers.requestHandler(),);
// credentialsRequired:false
// .unless({ path: ['/graphql'] })
app.use('/graphql',jwt({ secret: publicKey }),graphqlHTTP((request) => ({
schema: executableSchema,context: { pgPool,user: request.user },graphiql: !production,customFormatErrorFn(error) {
global.logger.error(`${error} returning String`);
Sentry.captureException(error);
return error;
},})));
// app.use('/healthz',healthCheck({ pgPool }));
const key = process.env.PRIVATE_KEY;
const cert = process.env.CERTIFICATE;
const ca = process.env.CA_CERT;
if (production) {
global.logger.info('---- Server certificate ----');
global.logger.info(cert);
global.logger.info('---- End server certificate ----');
}
const server = production
? https.createServer({ key,cert,ca },app)
: http.createServer(app);
app.use(Sentry.Handlers.errorHandler());
server.listen(port,() => {
global.logger.info(`Started in ${(now() - startTime).toFixed(2)}ms`);
global.logger.info(`Server running on port ${port}`);
});
});
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。