postal icon indicating copy to clipboard operation
postal copied to clipboard

SSLs not being renewed

Open iammattmartin opened this issue 9 years ago • 16 comments

Hot on the heels of #261, it looks like none of the SSLs as being renewed. Some expire in the next few hours.

I cannot see any docs on having to run anything manually to do this but I would have assumed a background process would have done that.

Is there a command to run to force this (or make it happen)?

iammattmartin avatar Jul 25 '17 12:07 iammattmartin

Can you try renewing in the console? postal console

RenewTrackCertificatesJob.perform

adamcooke avatar Jul 25 '17 14:07 adamcooke

Should I get any output?

root:~# postal console
Loading production environment (Rails 5.0.2)
irb(main):001:0> RenewTrackCertificatesJob.perform
=> []
irb(main):002:0>

iammattmartin avatar Jul 25 '17 15:07 iammattmartin

It does not appear to have done anything and they've expired now :(

Bar manually pasting in SSL keys/certificates in the database, is there any alternative?

iammattmartin avatar Jul 25 '17 17:07 iammattmartin

Can you check the renew_after date in your track_certificates table? You should get output if there are certs to renew when running the RenewTrackCertificatesJob job if there are certs to actually renew.

You can also check your lets_encrypt.log file to see if/when they have been renewed automatically. There might be an issue with the new cert being applied.

adamcooke avatar Jul 25 '17 18:07 adamcooke

It looks like that date was after the current SSL expiry date. 😨

I popped the date to be before now so it would do something and well, this error might be why.

irb(main):001:0> RenewTrackCertificatesJob.perform
Faraday::ConnectionFailed: Connection reset by peer
	from /usr/lib/ruby/2.3.0/openssl/buffering.rb:178:in `sysread_nonblock'
	from /usr/lib/ruby/2.3.0/openssl/buffering.rb:178:in `read_nonblock'
	from /usr/lib/ruby/2.3.0/net/protocol.rb:154:in `rbuf_fill'
	from /usr/lib/ruby/2.3.0/net/protocol.rb:106:in `read'
	from /usr/lib/ruby/2.3.0/net/http/response.rb:291:in `block in read_body_0'
	from /usr/lib/ruby/2.3.0/net/http/response.rb:276:in `inflater'
	from /usr/lib/ruby/2.3.0/net/http/response.rb:281:in `read_body_0'
	from /usr/lib/ruby/2.3.0/net/http/response.rb:202:in `read_body'
	from /usr/lib/ruby/2.3.0/net/http/response.rb:227:in `body'
	from /usr/lib/ruby/2.3.0/net/http/response.rb:164:in `reading_body'
	from /usr/lib/ruby/2.3.0/net/http.rb:1445:in `transport_request'
	from /usr/lib/ruby/2.3.0/net/http.rb:1407:in `request'
	from /usr/lib/ruby/2.3.0/net/http.rb:1400:in `block in request'
	from /usr/lib/ruby/2.3.0/net/http.rb:853:in `start'
	from /usr/lib/ruby/2.3.0/net/http.rb:1398:in `request'
	from /opt/postal/vendor/bundle/ruby/2.3.0/gems/faraday-0.9.2/lib/faraday/adapter/net_http.rb:82:in `perform_request'
... 8 levels...
	from /opt/postal/vendor/bundle/ruby/2.3.0/gems/acme-client-0.5.5/lib/acme/client/resources/challenges/base.rb:13:in `verify_status'
	from /opt/postal/app/app/models/track_certificate.rb:57:in `verify'
	from /opt/postal/app/app/models/track_certificate.rb:35:in `get'
	from /opt/postal/app/app/jobs/renew_track_certificates_job.rb:6:in `block in perform'
	from /opt/postal/vendor/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/relation/delegation.rb:38:in `each'
	from /opt/postal/vendor/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/relation/delegation.rb:38:in `each'
	from /opt/postal/app/app/jobs/renew_track_certificates_job.rb:4:in `perform'
	from /opt/postal/app/lib/postal/job.rb:43:in `perform'
	from (irb):1
	from /opt/postal/vendor/bundle/ruby/2.3.0/gems/railties-5.0.2/lib/rails/commands/console.rb:65:in `start'
	from /opt/postal/vendor/bundle/ruby/2.3.0/gems/railties-5.0.2/lib/rails/commands/console_helper.rb:9:in `start'
	from /opt/postal/vendor/bundle/ruby/2.3.0/gems/railties-5.0.2/lib/rails/commands/commands_tasks.rb:78:in `console'
	from /opt/postal/vendor/bundle/ruby/2.3.0/gems/railties-5.0.2/lib/rails/commands/commands_tasks.rb:49:in `run_command!'
	from /opt/postal/vendor/bundle/ruby/2.3.0/gems/railties-5.0.2/lib/rails/commands.rb:18:in `<top (required)>'
	from bin/rails:4:in `require'
	from bin/rails:4:in `<main>'

Not sure where it is connecting to but this server has nothing outbound stopping it from connecting.

iammattmartin avatar Jul 25 '17 18:07 iammattmartin

Looks like an error talking to Let's Encrypt. Not seen that before though.

adamcooke avatar Jul 25 '17 18:07 adamcooke

A second time around it worked just fine.

Could the process get confused and consider that a success and then mark the database as such?

iammattmartin avatar Jul 25 '17 18:07 iammattmartin

The renew_after date is set with the logic below. The expiry date comes from the certificate itself so in order for it to be in the future, it would have needed to have been renewed successfully.

self.renew_after = (self.expires_at - 1.month) + rand(10).days

Was the expires_at date in the table in the past or future?

adamcooke avatar Jul 25 '17 18:07 adamcooke

The expires at was correct, but the renew after seemed to be in the future, after expiry. That may have just been a coincidence.

However, have found another issue which will have affected this.

CAA DNS record types apply to all hosts under the root domain - we had this set for the CA that we use.

Worth adding to the guide that if you use the same domain and protect the domain from only a set CA, LE won't issue anything (but won't complain either).

CAA 128 issue "letsencrypt.org"

Might be worth having the GUI check for and alert on that maybe? :)

Thanks for the help.

iammattmartin avatar Jul 25 '17 18:07 iammattmartin

When I run this 'RenewTrackCertificatesJob' I get the following error in letsencrypt log file:

[27379] [2017-07-25T18:48:36.714] INFO -- : Error: Acme::Client::Error::Unauthorized (Must agree to subscriber agreement before any further actions) [27379] [2017-07-25T18:48:37.692] INFO -- : Error: Acme::Client::Error::Unauthorized (Must agree to subscriber agreement before any further actions)

What could be wrong?

webhostinggeek avatar Jul 25 '17 18:07 webhostinggeek

Guessing you didn't follow >> https://github.com/atech/postal/wiki/Click-&-Open-Tracking

iammattmartin avatar Jul 25 '17 18:07 iammattmartin

also, running 'postal register-lets-encrypt [email]' is giving below:

"Faraday::ConnectionFailed: execution expired"

webhostinggeek avatar Jul 25 '17 18:07 webhostinggeek

Looks like LE might be having issues.

iammattmartin avatar Jul 25 '17 19:07 iammattmartin

Nope, but please don't cross post. Someone will reply on the other issue when possible no doubt.

iammattmartin avatar Jul 25 '17 19:07 iammattmartin

Hello, when I try to perform "RenewTrackCertificatesJob.perform" from postal console I get this error, how could I debug this problem?

irb(main):004:0> RenewTrackCertificatesJob.perform
Faraday::ConnectionFailed: execution expired
        from app/models/track_certificate.rb:35:in `get'
        from app/jobs/renew_track_certificates_job.rb:6:in `block in perform'
        from app/jobs/renew_track_certificates_job.rb:4:in `perform'
        from lib/postal/job.rb:43:in `perform'
        from (irb):4

thanks

afanjul avatar Apr 11 '22 10:04 afanjul

@afanjul that means your computer was unable to talk to Lets Encrypt for whatever reason, I'd suggest trying again or upgrading to v2 where this is no longer necessary

willpower232 avatar Apr 12 '22 08:04 willpower232