Skip to content

Enhancement: manual IP specification during server:ca:install command #584

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

ramity
Copy link

@ramity ramity commented Mar 13, 2025

Hi, all.

I hit a bit of an admittedly fringe issue during some dev work and needed to be able to add a local IP to the list of ips added to the cert generated during the server:ca:install go script. I extended the go script with an additional StringFlag with a default value matching the current hardcoded value to preserve the current functionality.

@ramity ramity marked this pull request as ready for review March 13, 2025 05:58
@ramity ramity marked this pull request as draft March 13, 2025 21:39
@ramity
Copy link
Author

ramity commented Mar 13, 2025

Just got around to testing locally. I downloaded the most recent release artifact from my PR locally and instead of running the following in my dockerfile:

RUN curl -1sLf 'https://dl.cloudsmith.io/public/symfony/stable/setup.deb.sh' | bash
RUN apt install -y symfony-cli

I substituted it with:

COPY data/core-backend/custom-symfony-binary.zip /tmp/custom-symfony-binary.zip
RUN cd /tmp && unzip /tmp/custom-symfony-binary.zip -d /tmp
RUN cd /tmp && tar -xvzf /tmp/symfony-cli_linux_amd64.tar.gz
RUN mv /tmp/symfony /usr/local/bin/symfony

With the custom binary installed, I ran:

symfony server:ca:install --ips="192.168.1.4,localhost,127.0.0.1,::1"

Which produced a certificate with the 4 IPs listed correctly:

image

I tested without the ips flag specified and got an error, so marking as draft while I figure that out.

ramity added 3 commits March 13, 2025 16:58
… array

When running without --ips="..." flag, ips is "" rather than being sourced by the DefaultText attribute as previously thought. I restored the previous hardcoded string array and use the ips value if it evaluates to as truthy.
Look away my lack of go experience is showing
@ramity
Copy link
Author

ramity commented Mar 13, 2025

Ready for review but could use an additional test, see remaining section below

I resolved the issue and repeated my build process to generate a cert without the flag being set and produced the following cert:

image

Use case

My use case for this mostly stems from using a separate devices to host and access my dev environments. I'm exploring progressive web app related work, so the baked in path for https in a single command was very nice. Only issue is that accessing the site from an external client instead of localhost will generate a cert error since it's not being served over a valid ip. With this PR, I can add the additional IP to resolve the cert error to simply a cert authority error, which can be resolved with adding the cert locally.

I'm unsure if this functionality is really applicable to many or best practice. Some conversation on that wouldn't hurt, but this achieves what I need it to.

Remaining

I'm a little unfamiliar with go, but if someone could point me to where the server:ca:install command is being tested during the release runner, I could add an additional test case to test with the ips flag set.

@ramity ramity marked this pull request as ready for review March 13, 2025 22:32
@ramity
Copy link
Author

ramity commented Mar 13, 2025

The fruits of my labor - a valid service worker served over https from another computer local on the network running a docker container running symfony server.

image

@tucksaun
Copy link
Member

I’m not sure I would recommend adding the certificates we generate on another system that the local system where it has been generated.

Also, the default.p12 certificate is used by default for all instances of the Symfony CLI so removing localhost and 127.0.0.1 can lead to unexpected issues.

Additionally, the remote IP can change at any time, with this implementation it means we need to make possible to regenerate it when needed.

Finally, supporting this in server:ca:install means it also needs to be supported in local:server:start.

IF we follow this path I think I would rather generate a certificate on the fly based on the listenIP to avoid any conflicts or user errors.

However, I might have a solution for you: the HTTPS proxy usage seems to cover your use case as it’s reachable on other IPs and the certificate generation based on DNS names means no issue with IP change. would that work for you?

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

Successfully merging this pull request may close these issues.

2 participants