regression in GitLab 15.10: outgoing mail fails to verify TLS cert even though TLS is off
Summary
Since the Omnibus GitLab 15.10 upgrade this morning, mail isn't going out of GitLab.
Steps to reproduce
Unclear. Everything was working fine, then we upgraded to 15.10 and mail is not going on.
Example Project
This probably does not affect gitlab.com.
What is the current bug behavior?
Postfix is reporting the following errors in its logs;
Mar 23 07:04:22 gitlab-02/gitlab-02 postfix/smtpd[26601]: connect from localhost[::1]
Mar 23 07:04:22 gitlab-02/gitlab-02 postfix/smtpd[26601]: SSL_accept error from localhost[::1]: -1
Mar 23 07:04:22 gitlab-02/gitlab-02 postfix/smtpd[26601]: warning: TLS library problem: error:14094418:SSL routines:ssl3_read_bytes:tlsv1 alert unknown ca:../ssl/record/rec_layer_s3.c:1543:SSL alert number 48:
Mar 23 07:04:22 gitlab-02/gitlab-02 postfix/smtpd[26601]: lost connection after STARTTLS from localhost[::1]
Mar 23 07:04:22 gitlab-02/gitlab-02 postfix/smtpd[26601]: disconnect from localhost[::1] ehlo=1 starttls=0/1 commands=1/2
Trying to send an email as per the email not sent troubleshooting procedure gives me:
root@gitlab-02:/var/log/gitlab/gitlab-rails# sudo gitlab-rails console
[...]
irb(main):003:0> ActionMailer::Base.delivery_method
=> :smtp
irb(main):004:0> ActionMailer::Base.smtp_settings
=>
{:user_name=>nil,
:password=>nil,
:address=>"localhost",
:port=>25,
:domain=>"localhost",
:enable_starttls_auto=>false,
:tls=>false,
:ssl=>false,
:openssl_verify_mode=>"none",
:ca_file=>"/opt/gitlab/embedded/ssl/certs/cacert.pem"}
irb(main):005:0>
irb(main):006:0> Notify.test_email('anarcat@torproject.org', 'Hello World', 'This is a test message').deliver_now
Delivered mail 641c797273ba1_86be948d03829@gitlab-02.mail (7.2ms)
/opt/gitlab/embedded/lib/ruby/gems/3.0.0/gems/net-protocol-0.1.3/lib/net/protocol.rb:46:in `connect_nonblock': SSL_connect returned=1 errno=0 state=error: certificate verify failed (self signed certificate in certificate chain) (OpenSSL::SSL::SSLError)
Note that our mail server does use a rather odd TLS certificate with a local CA (which is self-signed and not in global trust anchors), I have tried adding it as a ca_file
but that doesn't work either:
irb(main):001:0> ActionMailer::Base.smtp_settings
=>
{:user_name=>nil,
:password=>nil,
:address=>"localhost",
:port=>25,
:domain=>"localhost",
:enable_starttls_auto=>false,
:tls=>false,
:ssl=>false,
:openssl_verify_mode=>"none",
:ca_file=>"/etc/ssl/torproject-auto/servercerts/ca.crt"}
irb(main):002:0> Notify.test_email('devnull@torproject.org', 'Hello World', 'This is a test message').deliver_now
Delivered mail 641c7ac7244af_888d348d0372a@gitlab-02.mail (7.7ms)
/opt/gitlab/embedded/lib/ruby/gems/3.0.0/gems/net-protocol-0.1.3/lib/net/protocol.rb:46:in `connect_nonblock': SSL_connect returned=1 errno=0 state=error: certificate verify failed (self signed certificate in certificate chain) (OpenSSL::SSL::SSLError)
What is the expected correct behavior?
Mail should be delivered. In fact, I'm puzzled as to why GitLab is trying to send email over TLS given that:
:enable_starttls_auto=>false,
:tls=>false,
:ssl=>false,
:openssl_verify_mode=>"none",
Relevant logs and/or screenshots
See above.
Output of checks
Results of GitLab environment info
Expand for output related to GitLab environment info
root@gitlab-02:~# sudo gitlab-rake gitlab:env:info System information System: Debian 11 Current User: git Using RVM: no Ruby Version: 3.0.5p211 Gem Version: 3.2.33 Bundler Version:2.3.15 Rake Version: 13.0.6 Redis Version: 6.2.8 Sidekiq Version:6.5.7 Go Version: unknown GitLab information Version: 15.10.0 Revision: 496a1d765be Directory: /opt/gitlab/embedded/service/gitlab-rails DB Adapter: PostgreSQL DB Version: 12.12 URL: https://gitlab.torproject.org HTTP Clone URL: https://gitlab.torproject.org/some-group/some-project.git SSH Clone URL: git@gitlab.torproject.org:some-group/some-project.git Using LDAP: no Using Omniauth: yes Omniauth Providers: GitLab Shell Version: 14.18.0 Repository storages: - default: unix:/var/opt/gitlab/gitaly/gitaly.socket GitLab Shell path: /opt/gitlab/embedded/service/gitlab-shell
Results of GitLab application Check
Expand for output related to the GitLab application check
root@gitlab-02:~# sudo gitlab-rake gitlab:check SANITIZE=true Checking GitLab subtasks ...Checking GitLab Shell ...
GitLab Shell: ... GitLab Shell version >= 14.18.0 ? ... OK (14.18.0) Running /opt/gitlab/embedded/service/gitlab-shell/bin/check Internal API available: OK Redis available via internal API: OK gitlab-shell self-check successful
Checking GitLab Shell ... Finished
Checking Gitaly ...
Gitaly: ... default ... OK
Checking Gitaly ... Finished
Checking Sidekiq ...
Sidekiq: ... Running? ... yes Number of Sidekiq processes (cluster/worker) ... 1/1
Checking Sidekiq ... Finished
Checking Incoming Email ...
Incoming Email: ... Checking Reply by email ...
IMAP server credentials are correct? ... Checking git@gitlab.torproject.org yes Mailroom enabled? ... skipped MailRoom running? ... skipped
Checking Reply by email ... Finished
Checking Incoming Email ... Finished
Checking LDAP ...
LDAP: ... LDAP is disabled in config/gitlab.yml
Checking LDAP ... Finished
Checking GitLab App ...
Database config exists? ... yes All migrations up? ... yes Database contains orphaned GroupMembers? ... no GitLab config exists? ... yes GitLab config up to date? ... yes Cable config exists? ... yes Resque config exists? ... yes Log directory writable? ... yes Tmp directory writable? ... yes Uploads directory exists? ... yes Uploads directory has correct permissions? ... yes Uploads directory tmp has correct permissions? ... yes Systemd unit files or init script exist? ... skipped (omnibus-gitlab has neither init script nor systemd units) Systemd unit files or init script up-to-date? ... skipped (omnibus-gitlab has neither init script nor systemd units) Projects have namespace: ... 230/10 ... yes [...] Redis version >= 6.0.0? ... yes Ruby version >= 2.7.2 ? ... yes (3.0.5) Git user has default SSH configuration? ... yes Active users: ... 2497 Is authorized keys file accessible? ... yes GitLab configured to store new projects in hashed storage? ... yes All projects are in hashed storage? ... yes
Checking GitLab App ... Finished
Checking GitLab subtasks ... Finished
Possible fixes
Unclear. It seems like a regression in the way GitLab talks with the mail server, but the GitLab 15 upgrade page doesn't mention anything specific in the 15.10 release. I've also looked in the changelog and nothing stroke me as significant.