Uses Herd or Valet certificate when available #46
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR improves SSL support for local development.
Those who use
herd secure
orvalet secure
for local development will already have access to an SSL certificate which is trusted by their machine meaning they don't need to instruct their browser to trust it as is the case with self-signed certificates.In most cases, Reverb will start on
0.0.0.0
orlocalhost
, which is also where sites served by Herd or Valet will resolve. This means, assuming a site is running onexample.test
, Reverb will be accessible from bothws://0.0.0.0:8080
andws://example.test:8080
. As such, we can use the existing certificate forexample.test
when instantiating the Reverb server.To make this work, we need to know on which site the user wishes to make Reverb accessible. This can be set using the new
REVERB_SERVER_HOSTNAME
environment variable or by passing the--hostname
option when starting the command.I made the decision not to default the hostname to the
APP_URL
even though it seems like this would be the most likely setting in local development. However, in production where Reverb is likely to be running on a different hostname to the app behind a reverse proxy, this doesn't make sense. Additionally, a hostname is not needed when running without TLS locally, which I assume is most likely to be the case.When a hostname is discoverd by Reverb, it will look for a matching certificate in the certificate directory of both Herd and Valet, using the certificate file paths when instantiating the server.