We started seeing some strange errors in our logs that normally appear when ruby isn't compiled properly with OpenSSL. But it's inconcistent...
We're getting errors like:
RuntimeError: Unsupported digest algorithm (SHA256).
(also with other digests, likesha1
). example error traceFaraday::SSLError (SSL_CTX_new: (null))
example error trace
We managed to reproduce it when starting unicorn using service unicorn start
or systemctl start unicorn
. But only with some requests... Not all of them. Some requests that use OpenSSL under the hood do work. Others don't.
However, when we start unicorn with /etc/init.d/unicorn start
, everything works without a hitch. (to clarify, systemd starts the same /etc/init.d
script)
We tried debugging ENV
vars, user permissions, file/dir ownership, recompile ruby, bootstrap a new server from scratch... Nothing seems to help.
In case this helps:
What are we missing? What can we try that we haven't thought of?
UPDATE 1
- output of some debug commands, e.g. OpenSSL, ruby etc
- PATH is being set inside the init.d script
- unicorn is being executed via su into www-data user
- The same problem happens when we use this unicorn.service file in
/etc/systemd/system
- We're running Ubuntu 16.04 on Gcloud
- Ruby was not installed via
apt
(explicitly removed, in case platform came pre-installed) and compiled from scratch. We're currently running 2.3.4 and tried also 2.3.6. Compiled either manually or using ruby-build. Norbenv
, norRVM
. - We install libssl-dev via
apt
(we're runningapt-get install -y autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm3 libgdbm-dev
before building ruby)
UPDATE 2
We're using a scripted/repeatable build process for the VM (using fabric), and this problem is consistent on multiple VMs we bootstrapped on GCloud. We then tried a VM on DigitalOcean with the same bootstrap scripts, and the problem doesn't seem to appear there.
In both cases we picked Ubuntu 16.04 64bit base image, but obviously there are some differences with kernel versions, base installed packages etc...
UPDATE 3
The problem simply vanished. See my answer below.
Environment="PATH=/bin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/local/sbin:/sbin"
– Graaf