-
-
Notifications
You must be signed in to change notification settings - Fork 10
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
generate web certificate self signed by CA #46
generate web certificate self signed by CA #46
Conversation
The The file After install Certificat Authority on system, curl work fine (without
Unfortunately no browser accept the CA Root. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made some suggestions and added some questions regarding this enchanting PR 👍
- Informational messages should add value to the end user, and you display the exit status for
runa
commands, which doesn't realy add value IMO. I think that maybe you could keep them usingtrace!()
instead ofinfo!()
, and perhaps useinfo!()
to display only some "success" message that tell the user what the process is doing :) - We need to make sure the CA directory is the same for all distros, I'd like some research or feedback before we push it, or at least we should add more verbose warnings to users (like telling them that "the CA dir wasn't found in {checked_location}" for instance)
- I'd even suggest a way to customize it with an env var, something like
RYMFONY_CA_DIR
, so people doing weird stuff, or unknown distros, can still have a workaround.
I'm so glad you worked on this! This was on the top of the roadmap, so thanks a lot 👍
src/commands/ca_install.rs
Outdated
if cfg!(target_os = "windows") { | ||
window_ca_install(&certificate_path); | ||
} else if cfg!(target_os = "linux") { | ||
ubuntu_ca_install(&certificate_path); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ubuntu_ca_install(&certificate_path); | |
linux_ca_install(&certificate_path); |
src/commands/ca_install.rs
Outdated
// writeln!("End Of Work"); | ||
} | ||
|
||
fn ubuntu_ca_install(certificate_path: &PathBuf) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fn ubuntu_ca_install(certificate_path: &PathBuf) { | |
fn linux_ca_install(certificate_path: &PathBuf) { |
src/commands/ca_install.rs
Outdated
} | ||
|
||
fn ubuntu_ca_install(certificate_path: &PathBuf) { | ||
let ubuntu_cert_path = PathBuf::from("/usr/local/share/ca-certificates/"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should make sure this is the same path for other distros than Ubuntu. Did you check for Alpine, Arch, RedHat or others?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This process is good for all Debian based distros.
I don't know for other distros. I need search how to it.
let subject_alt_name = SubjectAlternativeName::new() | ||
.dns("localhost") | ||
.ip("127.0.0.1") | ||
.ip("::1") | ||
.build(&cert_builder.x509v3_context(Some(ca_cert), None))?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Curiosity here: Do you think we could somehow "externalize" this part in order to allow users to create CA/certs for custom local domains in the future? Symfony CLI is doing it but only with the .wip
domain, I'd personally like users to be able to add any domain (some people use .docker
or .local
for instance).
At some point, it could even use runa
to open /etc/hosts
/ c:\Windows\system32\drivers\etc\hosts
in order to add the domain and make it point to 127.0.0.1
without the user having to do it themselves (which would be kind of a revolution, since no dnsmasq config or anything, means a lot!)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have same idea. Add command to add domain into certificate.
The list of domain can be stored into .rymfony
directory and used to update the hosts
file (with specific command).
But :
- If a domain is already in
hosts
file, do not add. - add comment into hosts file to prevent change this section? Like Flex add in
.env
file on install.
Preview:
### Rymfony Domain
127.0.0.1 my-domain.local
::1 my-domain.local
127.0.0.1 admin.my-domain.local
::1 admin.my-domain.local
### END Rymfony Domain
Add this feature is for an new PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If a domain is already in
hosts
file, do not add.
Seems obvious to me to avoid duplications 👍
add comment into hosts file to prevent change this section? Like Flex add in
.env
file on install.
I like the idea, Docker Desktop does it too, but I think it might over-complexify the process. If you already know how to do that with good performances, that may be good, but I think it might introduce a bit of overhead. Also, it is error-prone if anyone modifies the comment section (that's also one problem with Flex, by the way).
I think one line-comment could be good, like this:
127.0.0.1 my-domain.local # Added by Rymfony
::1 my-domain.local # Added by Rymfony
And for the "where do we put this", this could be on top of the file.
We could put it after all the comments lines that serve as disclaimer on Windows for example. It's easy to check (open the file, check the first characters of the line, and if it's #
or a non-empty trimmed line, move to next line).
I'm also okay for a second PR :)
The folder and the process can be changed between Linux distribution. That's why I put the name of the function with One of source used to know how to add CA Root on systems: https://manuals.gfi.com/en/kerio/connect/content/server-configuration/ssl-certificates/adding-trusted-root-certificates-to-the-server-1605.html If no folder is found, I suggest to inform the user of the location of the CA Root to add itself into their system.
As the process to add a CA Root into *nix system is not same, this env var cannot be used.
I'm glad you enjoyed my work. I've wanted to use Rust for a long time. But I never had a really serious project. Your live on Rust development for PHP developers introduced me to your project. 😃 |
Co-authored-by: Alex Rock <pierstoval@gmail.com>
Thanks for the clarification about CA root on *nix systems 👍 We'll keep the code as-is with your PR, and if anyone has issue, we'll change it then 😉 |
I just tested this branch locally, removed existing certificates in Here's what I got:
No idea on what's going on though, nor whether it is a bug 🤣 |
I have tested only on Linux Mint this feature. You have run rymfony on WSDL ? What is your configuration ? |
I'm running it with Powershell on a native Windows 10 Pro machine. I have tested with WSL and it works normally :) |
Curl on windows don't use the system certificate manager. You need add the Rymfony CA Root into the CA bundle |
Ok, I'm using the |
Now I have an other error:
Removing certs in Note:
|
The command Have you add the Rymfony CA root into the cURL ca bundle ? |
Well, I couldn't successfully add it to Windows, but when using Curl's |
Firefox, Chromium and Edge works too? |
Could test Firefox, Brave, IE and Edge, and it works 👍 I think we can merge it, don't you think? |
Yes you can merge. |
Thank you @macintoshplus |
This PR allow generate SSL certificate for CA and Web Certificate for localhost, 127.0.0.1 and ::1.
Fix partially #45
Result on Firefox:
Chromium:
ToDo: