typisttech/vagrant-trellis-cert

undefined method `sysclose' for nil:NilClass

ethicka opened this issue · 3 comments

Getting an undefied method error when I run the trust command.

$ vagrant trellis-cert trust
Importing certificates...
This command was not invoked properly. The help for this command is
available below.

undefined method `sysclose' for nil:NilClass

Backtrace:
/Users/local/.vagrant.d/gems/2.4.4/gems/vagrant-trellis-cert-0.5.0/lib/vagrant_plugins/trellis_cert/certificate.rb:35:in `ensure in fetch'
/Users/local/.vagrant.d/gems/2.4.4/gems/vagrant-trellis-cert-0.5.0/lib/vagrant_plugins/trellis_cert/certificate.rb:36:in `fetch'
/Users/local/.vagrant.d/gems/2.4.4/gems/vagrant-trellis-cert-0.5.0/lib/vagrant_plugins/trellis_cert/certificate.rb:15:in `download'
/Users/local/.vagrant.d/gems/2.4.4/gems/vagrant-trellis-cert-0.5.0/lib/vagrant_plugins/trellis_cert/command/trust.rb:58:in `block (2 levels) in trust'
/Users/local/.vagrant.d/gems/2.4.4/gems/vagrant-trellis-cert-0.5.0/lib/vagrant_plugins/trellis_cert/command/trust.rb:56:in `map'
/Users/local/.vagrant.d/gems/2.4.4/gems/vagrant-trellis-cert-0.5.0/lib/vagrant_plugins/trellis_cert/command/trust.rb:56:in `block in trust'
/opt/vagrant/embedded/lib/ruby/2.4.0/tmpdir.rb:89:in `mktmpdir'
/Users/local/.vagrant.d/gems/2.4.4/gems/vagrant-trellis-cert-0.5.0/lib/vagrant_plugins/trellis_cert/command/trust.rb:55:in `trust'
/Users/local/.vagrant.d/gems/2.4.4/gems/vagrant-trellis-cert-0.5.0/lib/vagrant_plugins/trellis_cert/command/trust.rb:20:in `execute'
/Users/local/.vagrant.d/gems/2.4.4/gems/vagrant-trellis-cert-0.5.0/lib/vagrant_plugins/trellis_cert/command/root.rb:37:in `execute'
/opt/vagrant/embedded/gems/2.1.1/gems/vagrant-2.1.1/lib/vagrant/cli.rb:54:in `execute'
/opt/vagrant/embedded/gems/2.1.1/gems/vagrant-2.1.1/lib/vagrant/environment.rb:275:in `cli'
/opt/vagrant/embedded/gems/2.1.1/gems/vagrant-2.1.1/bin/vagrant:156:in `<main>'

sysclose is an openssl method per my understanding.

My vagrant is version 2.1.1.

Vagrant is running:

$ /opt/vagrant/embedded/bin/openssl version
OpenSSL 1.1.0g  2 Nov 2017

While, locally I brew installed openssl:

$ /usr/bin/openssl version
LibreSSL 2.2.7

I googled and people with similar issues symlink to the local version (sudo ln -sf /usr/bin/openssl /opt/vagrant/embedded/bin/openssl), but I wanted to flag in case there's another more stable solution.

2 issues happening here:

  • the ensure block not handling "ssl_client is nil" properly
  • these lines failed:
    tcp_client = TCPSocket.new(@host, 443)
    ssl_client = OpenSSL::SSL::SSLSocket.new(tcp_client)

v0.5.1 fixed the first issue.

Please update and re-run $ vagrant trellis-cert trust.
v0.5.1 should give us a better error message.

Yes, definitely a more useful error message:

Failed to connect to port 443: wordpress.local Connection refused

I ran vagrant provision again and it shook it out. It's working right now, but not sure it will work after restart.

Maybe nginx is not running on boot?
See: roots/trellis#980

Closing this issue because we require the HTTPS site to be up and running before using the command. Ask on the roots forum if $ vagrant up doesn't bring up the site.