Quantcast
Channel: Active questions tagged https - Stack Overflow
Viewing all articles
Browse latest Browse all 1499

How to fix HTTPS on express-gateway

$
0
0

I'm running a micro-service API, and I use express-gateway. This API has been running since 1 years. I need to implement HTTPS connection to it, and I have difficulties to do.

I've generated SSL certificate thanks to openssl. I have server keys and clients key.

I've configurate my gateway this way gateway.config.yml:

http: port: 8000https:  port: 9443  hostname: localhost  tls:"default":        key: ‘path/to/server.key'        cert: 'path/to/server.crt'admin:  port: 9876  host: localhostapiEndpoints:  api:    host: '*'    paths: '/ip'  test:    host: '*'    paths: ['/test', '/test/*']  voice:    host: '*'    paths: ['/voices', '/voices/*']serviceEndpoints:  httpbin:    url: 'https://httpbin.org'  testService:    url: 'http://localhost:6969'  voiceService:    url: 'http://localhost:6965'policies:  - basic-auth  - cors  - expression  - key-auth  - log  - oauth2  - proxy  - rate-limitpipelines:  default:    apiEndpoints:      - api    policies:      - proxy:          - action:              serviceEndpoint: httpbin              changeOrigin: true  testPipeline:    apiEndpoints:      - test    policies:      - proxy:          - action:              serviceEndpoint: testService              changeOrigin: true  voicePipeline:    apiEndpoints:      - voice    policies:      - proxy:          - action:              serviceEndpoint: voiceService              changeOrigin: true

and here is my voice-service.js :

const express = require('express');const bodyParser = require('body-parser');const cors = require('cors');const middleware = require('./middleware/index');const firebase = require('./config/firebase-config');const { spawn, execSync } = require('child_process');const fs = require('fs');const app = express();const port = 6965;var jsonParser = bodyParser.json();app.use(express.json({limit: '100mb'}));app.use(cors());app.use(middleware.decodeToken);app.get('/', (req, res) => {    res.send('Welcome to the Voice API');})app.get('/voices', async (req, res) => {    ...});app.post('/voices', jsonParser, async (req, res) => {    ...});app.delete('/voices', async (req, res) => {    ...});app.listen(port, () => {    console.log(`server is running on port ${port}`);});

My API use firebase bearers tokens and have a middleware to check it validity middleware.js :

const admin = require('../config/firebase-config');class Middleware {    async decodeToken(req, res, next) {        try {            const token = req.headers.authorization.split('')[1];            const decodeValue = await admin.admin.auth().verifyIdToken(token);            if (decodeValue)                return next();            return res.json({ message: 'Invalid Token' });        } catch (e) {            return res.json({ message: 'Invalid Token' });        }    }}module.exports = new Middleware();

When I tried to test https, I tried with Postman. I added my client ssl key into it and a valid bearer token. I tried to get the 'voices/' route. With http method it's working fine, but with https it's always result timeout.

Could anyone help me?I tried to be as exhaustive as I can but if you need more informations, ask it!


Viewing all articles
Browse latest Browse all 1499

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>