Fixes #670: Added support for printing out the Common Name from the SSL certificate that is being used.
Please ensure that your pull request fulfills these requirements:
- [ ] The pull request is being made against the
masterbranch- No. This is based on https://github.com/http-party/http-server/pull/674, but happy to rebase if that PR is rejected
- [x] Tests for the changes have been added (for bug fixes / features)
What is the purpose of this pull request? (bug fix, enhancement, new feature,...)
New Feature
Fixes #670: Added support for printing out the Common Name from the SSL certificate that is being used.
This avoids SSL errors when going to the host (such as a IP address) that doesn't match the name in the certificate.
What changes did you make?
- Within the bin/http-server the binary now checks the SSL cert is valid and extracts the common name. It then prints that common name as one of the options. A minor refactor of the printing was also made.
- Added unit tests for starting a SSL server. (Those tests can be kept, even without this new feature)
Provide some example code that this change will affect, if applicable:
N/A
Is there anything you'd like reviewers to focus on?
Please provide testing instructions, if applicable:
$ npm test
# Create cert (use localhost or whatever as a common name)
$ openssl req -newkey rsa:2048 -new -nodes -x509 -days 3650 -keyout key.pem -out cert.pem
# With ssl
$ bin/http-server -c-1 -S
Available on:
https://localhost:8080
...
# Without ssl
$ bin/http-server -c-1 -S
Available on:
https://127.0.0.1:8080
...
I think this looks really good! And I'm impressed by the small addition to grab something like that! Unfortunately, there have been some major changes in master, especially to the tests, and there are some pretty big conflicts to solve.