Skip to content

S/MIME signatures not working

Summary

Trying the new S/MIME commit signature verification feature on a self-managed install and getting: "An error occurred while loading commit signatures".

Steps to reproduce

Sign a commit with a S/MIME certificate (the certificate used is signed by an intermediate, which in turn is signed by a private CA).

Note: both the intermediate and root CA certificates are installed in /etc/gitlab/trusted-certs and gitlab-ctl reconfigure was run.

Push the commit to a repo.

Observe the commit log.

Example Project

https://gitlab.com/plinss/smime-test/-/commits/master

What is the current bug behavior?

Error: "An error occurred while loading commit signatures" when viewing commits.

What is the expected correct behavior?

Normal commit signature UI.

Relevant logs and/or screenshots

From /var/log/gitlab/gitlab-rails/production.log

Started GET "/peter/test/-/commits/master/signatures?utf8=%E2%9C%93&search=" for [ip-redacted] at 2020-02-22 19:53:19 -0800
Processing by Gitlab::RequestForgeryProtection::Controller#index as JSON
  Parameters: {"utf8"=>"✓", "search"=>""}
Completed 200 OK in 1ms (ActiveRecord: 0.0ms | Elasticsearch: 0.0ms | Allocations: 96)
Processing by Projects::CommitsController#signatures as JSON
  Parameters: {"utf8"=>"✓", "search"=>"", "namespace_id"=>"peter", "project_id"=>"test", "id"=>"master"}
Completed 500 Internal Server Error in 232ms (ActiveRecord: 16.2ms | Elasticsearch: 0.0ms | Allocations: 40672)
  
NoMethodError (undefined method `strip' for #<Array:0x00007ff1b3835f70>):
  
lib/gitlab/x509/commit.rb:109:in `block in certificate_crl'
lib/gitlab/x509/commit.rb:108:in `each'
lib/gitlab/x509/commit.rb:108:in `certificate_crl'
lib/gitlab/x509/commit.rb:151:in `issuer_attributes'
lib/gitlab/x509/commit.rb:158:in `certificate_attributes'
lib/gitlab/x509/commit.rb:172:in `attributes'
lib/gitlab/x509/commit.rb:195:in `create_cached_signature!'
lib/gitlab/x509/commit.rb:16:in `signature'
app/models/commit.rb:350:in `block in signature'
lib/gitlab/utils/strong_memoize.rb:30:in `strong_memoize'
app/models/commit.rb:345:in `signature'
app/controllers/projects/commits_controller.rb:49:in `block (3 levels) in signatures'
app/controllers/projects/commits_controller.rb:46:in `map'
app/controllers/projects/commits_controller.rb:46:in `block (2 levels) in signatures'
app/controllers/projects/commits_controller.rb:43:in `signatures'
app/controllers/application_controller.rb:559:in `block in allow_gitaly_ref_name_caching'
lib/gitlab/gitaly_client.rb:330:in `allow_ref_name_caching'
app/controllers/application_controller.rb:558:in `allow_gitaly_ref_name_caching'
ee/lib/gitlab/ip_address_state.rb:10:in `with'
ee/app/controllers/ee/application_controller.rb:43:in `set_current_ip_address'
app/controllers/application_controller.rb:478:in `set_current_admin'
lib/gitlab/session.rb:11:in `with_session'
app/controllers/application_controller.rb:469:in `set_session_storage'
lib/gitlab/i18n.rb:55:in `with_locale'
lib/gitlab/i18n.rb:61:in `with_user_locale'
app/controllers/application_controller.rb:463:in `set_locale'
lib/gitlab/application_context.rb:46:in `block in use'
lib/gitlab/application_context.rb:46:in `use'
lib/gitlab/application_context.rb:19:in `with_context'
app/controllers/application_controller.rb:454:in `set_current_context'
lib/gitlab/error_tracking.rb:34:in `with_context'
app/controllers/application_controller.rb:554:in `sentry_context'
lib/gitlab/request_profiler/middleware.rb:17:in `call'
ee/lib/gitlab/jira/middleware.rb:19:in `call'
lib/gitlab/middleware/go.rb:20:in `call'
lib/gitlab/etag_caching/middleware.rb:13:in `call'
lib/gitlab/middleware/multipart.rb:117:in `call'
lib/gitlab/middleware/read_only/controller.rb:53:in `call'
lib/gitlab/middleware/read_only.rb:18:in `call'
lib/gitlab/middleware/basic_health_check.rb:25:in `call'
lib/gitlab/middleware/request_context.rb:23:in `call'
config/initializers/fix_local_cache_middleware.rb:9:in `call'
lib/gitlab/metrics/requests_rack_middleware.rb:49:in `call'
lib/gitlab/middleware/release_env.rb:12:in `call'

Output of checks

(If you are reporting a bug on GitLab.com, write: This bug happens on GitLab.com)

Results of GitLab environment info

Expand for output related to GitLab environment info
System information
System:		Debian 10
Proxy:		no
Current User:	git
Using RVM:	no
Ruby Version:	2.6.5p114
Gem Version:	2.7.10
Bundler Version:1.17.3
Rake Version:	12.3.3
Redis Version:	5.0.7
Git Version:	2.24.1
Sidekiq Version:5.2.7
Go Version:	go1.11.6 linux/amd64

GitLab information Version: 12.8.0-ee Revision: 0bd32f78864 Directory: /opt/gitlab/embedded/service/gitlab-rails DB Adapter: PostgreSQL DB Version: 10.12 URL: https://gitlab.linss.com HTTP Clone URL: https://gitlab.linss.com/some-group/some-project.git SSH Clone URL: git@gitlab.linss.com:some-group/some-project.git Elasticsearch: yes Geo: no Using LDAP: yes Using Omniauth: yes Omniauth Providers: saml

GitLab Shell Version: 11.0.0 Repository storage paths:

  • default: /var/opt/gitlab/git-data/repositories GitLab Shell path: /opt/gitlab/embedded/service/gitlab-shell Git: /opt/gitlab/embedded/bin/git

Results of GitLab application Check

Expand for output related to the GitLab application check
Checking GitLab subtasks ...

Checking GitLab Shell ...

GitLab Shell: ... GitLab Shell version >= 11.0.0 ? ... OK (11.0.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 ... 1

Checking Sidekiq ... Finished

Checking Incoming Email ...

Incoming Email: ... Checking Reply by email ...

IMAP server credentials are correct? ... yes Init.d configured correctly? ... skipped MailRoom running? ... skipped

Checking Reply by email ... Finished

Checking Incoming Email ... Finished

Checking LDAP ...

LDAP: ... Server: ldapmain LDAP authentication... Success LDAP users with access to your GitLab server (only showing the first 100 results) User output sanitized. Found 2 users of 100 limit.

Checking LDAP ... Finished

Checking GitLab App ...

Git configured correctly? ... yes Database config exists? ... yes All migrations up? ... yes Database contains orphaned GroupMembers? ... no GitLab config exists? ... yes GitLab config up to date? ... 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 Init script exists? ... skipped (omnibus-gitlab has no init script) Init script up-to-date? ... skipped (omnibus-gitlab has no init script) Projects have namespace: ... 5/3 ... yes 5/4 ... yes 5/5 ... yes 5/6 ... yes 4/7 ... yes 4/10 ... yes 4/11 ... yes 4/12 ... yes 7/14 ... yes 7/15 ... yes 11/18 ... yes 4/19 ... yes 5/20 ... yes 4/21 ... yes 4/22 ... yes 4/24 ... yes 4/25 ... yes 10/26 ... yes 4/27 ... yes 4/29 ... yes 5/30 ... yes 5/31 ... yes 4/32 ... yes 5/34 ... yes 4/35 ... yes 5/36 ... yes 4/37 ... yes 4/38 ... yes 4/39 ... yes Redis version >= 2.8.0? ... yes Ruby version >= 2.5.3 ? ... yes (2.6.5) Git version >= 2.22.0 ? ... yes (2.24.1) Git user has default SSH configuration? ... yes Active users: ... 2 Is authorized keys file accessible? ... yes Elasticsearch version 5.6 - 6.x? ... yes (7.6.0)

Checking GitLab App ... Finished

Checking GitLab subtasks ... Finished

Possible fixes

This worked briefly when I tested it with an old certificate that did not use an intermediate. The 'undefined method strip for array' error makes me think this in only an issue when there are intermediate certificates and code is getting an array of certificates rather than a single certificate.