Skip to content

Conversation

@larryschirmer
Copy link

When opening an https connection I noticed that express-gateway/lib/gateway/server.js is having issues properly capturing the file path in the .yml.

The for in loop is trying to pull properties from httpsConfig.tls when the object is defined as an array

//httpsConfig
{
    "port": 9443,
    "tls": [
        {
            "localhost": {
                "key": "localhost.key.pem",
                "cert": "localhost.cert.pem"
            }
        },
        {
            "default": {
                "key": "localhost.key.pem",
                "cert": "localhost.cert.pem"
            }
        }
    ]
}

The issue was resolved by looping through the tls array and assigning each domain object to certPaths.

let domainCount = httpsConfig.tls.length;
let domainNames = [];

httpsConfig.tls.forEach(domainObj => {
Copy link
Member

@kevinswiber kevinswiber Aug 5, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be collapsed to something like:

const domainNames = httpsConfig.tls
  .map(Object.getOwnPropertyNames)
  .reduce((a, b) => a.concat(b));

It's throwing here when missing tls config.

@DrMegavolt I think you worked on this in the past. What behavior should we expect if no tls configuration exists? Should we log a warning? Exit with a config validation error? Thoughts?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kevinswiber great code condensing suggestion.

CircleCI is showing quite a few errors and warnings with my pull request. Is this all caused by a disruption from this change?

Also, if no tls option is set in gateway.config.yml for https i.e.

https:
  port: 9443

then npm start silently fails to begin listening on the specified port allowing the process to continue with no error output.

Should an error be thrown in this file to make a developer aware of the potential bug?

let domain = el;
let certPaths = httpsConfig.tls[el];
let domainCount = httpsConfig.tls.length;
const domainNames = httpsConfig.tls
Copy link
Contributor

@DrMegavolt DrMegavolt Aug 7, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kevinswiber @larryschirmer

this fails in Circle CI if not tls provided in https section. so additional check is needed (+test update to rm https section if it is not in use).

there is a variant TLS-PSK that does not need a certificate. And it seems to be not supported by node.js nodejs/node#6701

So until then certificates are required. And I would imaging throwing an error and preventing start would be a good option.

@altsang altsang changed the title Fix error in capturing key/cert file path Fix error in capturing key/cert file path - connects to #367 Aug 13, 2017
@larryschirmer
Copy link
Author

@DrMegavolt @kevinswiber
I would like to close this pull request, and replace it with a different pull request that addresses an easier error in the documentation. See latest comment in issue 367. Is there additional work that should be preserved from this pr before I close it?

@kevinswiber
Copy link
Member

@larryschirmer We can close this. No worries. Thanks for taking another stab at it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants