-
Notifications
You must be signed in to change notification settings - Fork 51
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
How to bind ssl cert with iodine + Rails? #94
Comments
Hi @danielnc , Thank you for your question and for your interest in iodine. In general, the iodine command line interface (CLI) doesn't necessarily match Puma. You will need to use the iodine CLI for the command line arguments. To get all available information about the iodine CLI usage, run (in the terminal): iodine -h SSL/TLS Command Line Interface (CLI)For SSL/TLS certificates, the best CLI approach would be: bundle exec iodine -p 3443 -key config/ssl/localhost.key -cert config/ssl/localhost.crt Or (with a specific IP binding): bundle exec iodine -p 3443 -b 127.0.0.1 -key config/ssl/localhost.key -cert config/ssl/localhost.crt SSL/TLS from RubyThe easiest way would be to update the Iodine::DEFAULT_SETTINGS[:tls] = Iodine::TLS.new(
private_key: "config/ssl/localhost.key",
certificate: "config/ssl/localhost.crt") The Other stuff to doThere's really little to do in order to use iodine as a drop in replacement for Puma. You would need to replace any calls to Puma's Iodine.on_state(:before_fork) do
# whatever
end Of course, iodine will perform better when using the built-in pub/sub and WebSocket layer (rather than using ActionCable). Also, iodine provides timers and task deferral methods that could also prove useful. You might consider running the Good luck with the transition 👍🏻 If you need anything else, let me know. Kindly, |
Bo, thanks for the info!! I am in the works for trying to get this deployed to our staging env and I am facing some problems with SSL cert. I don't see any alerts of failures but whenever I try to check if the connection is secure I am getting the following errors:
This is the logs and we can't find any issue
Maybe it's because of binding to If I try to curl
Help will be greatly appreciated :) |
Hi @danielnc , I'm not sure what's going on specifically. I will need to be able to replicate the issue in order to debug this. It would be great if you could post a small code example that has the same issue. However, I noticed your Also, are you using nginx or some other reverse proxy in front of iodine? - if you are (and I hope you are), it would make better sense to bind iodine to the reverse proxy using a Unix Socket or some other way. For me, when I run iodine with a self signed certificate, it runs okay ( Kindly, |
Hi @danielnc , Just a quick update: I tested iodine with TLS 1.3 and it works... which means that I'm not sure at all where the issue you're experiencing might lay. It might be in the way you initialize things. Maybe the certificate requires a password... I'm not sure. Could you test and tell me:
Also - could you run Kindly, P.S. Make suer to upgrade to Iodine 0.7.40, it has TLS specific patches. |
Hey @boazsegev, I was able to have it running with self-signed certificates (expired and valid). It works as expected. I've tried using env vars and parameters to specify the certificates and other configurations, and with/without However, when using a valid certificate it does not work. Executed tests with OpenSSL and curl. Simple ssl connect test, executed from the same container, and from a load balancer. No Nginx proxy at this time, since the basic webserver is not working with a direct connection. Ps: Updated to Iodine
Another result from a dev machine:
Logs from Iodine (snippet);
When executing
So far I have no idea of what is the issue. Best, |
Hi @raivil , Thank you for joining the conversation and for your help. I'm sorry if my responses are somewhat delayed, I have a big deadline on June 3rd and then I'll be playing catch-up for a while (trying to catch up with everything that was placed on hold). It appears from the logs that iodine is adding 2 certificates and a single key:
It is possible that your certificate file contains more certificates than keys, i.e., a certificate chain, containing the public certificate for the authority as well as your own certificate. However, iodine loads all these certificates as happens here: iodine/ext/iodine/fio_tls_openssl.c Lines 429 to 440 in 18d0aa1
This might be resolved by making the loop run only once... one option would be to comment out the loop instructions like this: // for (int i = 0; i < sk_X509_INFO_num(inf); ++i) { // <- !!!commented out!!!
/* for each element in PEM */
X509_INFO *tmp = sk_X509_INFO_value(inf, i);
if (tmp->x509) {
FIO_LOG_DEBUG("TLS adding certificate from PEM file.");
SSL_CTX_use_certificate(tls->ctx, tmp->x509);
}
if (tmp->x_pkey) {
FIO_LOG_DEBUG("TLS adding private key from PEM file.");
SSL_CTX_use_PrivateKey(tls->ctx, tmp->x_pkey->dec_pkey);
}
// } // <- !!!commented out!!! However, I'm not sure if this will break multi-domain certificates. I'll have to dig into this. For now, you could fork the repo and try commenting the lines out and see if that helps. Once I have more time, I'll try a few things myself. Kindly, |
Hey @boazsegev, Thank you so much for the help so far. Right now I'm out of bandwidth to fork the repo and execute the suggested tests. Best Regards, |
Hi
We are moving from puma to iodine because of performance and proper websocket creation with anycable/action_cable
I am wondering what would be the proper way to setup rails + iodine since I couldn't find a lot of documentation around it:
Is this enough?
Do I need to change config.ru from rails or do anything else? Again I couldn't find a lot of documentation on how to properly setup the server
Another thing is that I've created this initializer file:
But I can't find a way to setup ssl here
Any suggestions on how to do this, the rails way?
The text was updated successfully, but these errors were encountered: