Skip to content

use self-signed to integate gitlab with keycloak but see error: certificate verify failed (self signed certificate))

Summary

I have configured the gitlab with self-signed cert. keycloak has its own self-signed cert too. I have update the gitlab.rb to add the keycloak as the openid connect provider. when click the keycloak login button, the web return 500 error the and production log show: OpenIDConnect::Discovery::DiscoveryFailed (SSL_connect returned=1 errno=0 state=error: certificate verify failed (self signed certificate)):

Steps to reproduce

  1. config the gitlab with self-signed cert (also copy the crt to /etc/gitlab/trusted-certs/ folder I can access the https://gitlab.test.com from browser

  2. enable the https on keycloak. I can also login keycloak via https on browser. I convert the keycloak's jks file to PEM and copy to /etc/gitlab/trusted-certs/ folder

  3. edit the gitlab.rb. add below lines:


 gitlab_rails['omniauth_providers'] = [
   {
     'name' => 'openid_connect',
     'label' => 'keycloak',
     'args' => {
             'name' => 'openid_connect',
             'scope' => ['openid','profile'],
             'response_type' => 'code',
             'issuer' => 'https://192.168.31.148:8443/auth/realms/test',  // 192.168.31.148 is the ip of keycloak
             'discovery' => true,
             'client_auth_method' => 'query',
             'uid_field' => 'preferred_username',
             'client_options' => {
                'schema' => 'http',
                'identifier' => 'gitlab',
                'secret' => '6de3c7ea-54ee-427f-8ddd-7f64a59f6d01',
                'redirect_uri' => 'http://gitlab.test.com/users/auth/openid_connect/callback'

             }

     }
   }
 ]
  1. reconfig gitlab

  2. click the "keycloak" to login

What is the current bug behavior?

the page return 500 error. in production.log, I can see:

OpenIDConnect::Discovery::DiscoveryFailed (SSL_connect returned=1 errno=0 state=error: certificate verify failed (self signed certificate)):

lib/gitlab/middleware/rails_queue_duration.rb:27:in `call'
lib/gitlab/metrics/rack_middleware.rb:17:in `block in call'
lib/gitlab/metrics/transaction.rb:62:in `run'
lib/gitlab/metrics/rack_middleware.rb:17:in `call'
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/correlation_id.rb:16:in `block in call'
lib/gitlab/middleware/correlation_id.rb:15:in `call'
lib/gitlab/middleware/multipart.rb:117:in `call'
lib/gitlab/middleware/read_only/controller.rb:48:in `call'
lib/gitlab/middleware/read_only.rb:18:in `call'
lib/gitlab/middleware/basic_health_check.rb:25:in `call'
lib/gitlab/request_context.rb:32: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'

What is the expected correct behavior?

I expect the page should redirect to keycloak login page.

Results of GitLab environment info

Expand for output related to GitLab environment info

System information System: Proxy: no Current User: git Using RVM: no Ruby Version: 2.6.3p62 Gem Version: 2.7.9 Bundler Version:1.17.3 Rake Version: 12.3.3 Redis Version: 3.2.12 Git Version: 2.24.1 Sidekiq Version:5.2.7 Go Version: unknown

GitLab information Version: 12.6.3-ee Revision: 461e0ee8310 Directory: /opt/gitlab/embedded/service/gitlab-rails DB Adapter: PostgreSQL DB Version: 10.9 URL: https://gitlab.willy.com HTTP Clone URL: https://gitlab.willy.com/some-group/some-project.git SSH Clone URL: git@gitlab.willy.com:some-group/some-project.git Elasticsearch: no Geo: no Using LDAP: no Using Omniauth: yes Omniauth Providers: openid_connect

GitLab Shell Version: 10.3.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 >= 10.3.0 ? ... OK (10.3.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: ... Reply by email is disabled in config/gitlab.yml

Checking Incoming Email ... Finished

Checking LDAP ...

LDAP: ... LDAP is disabled in config/gitlab.yml

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? ... skipped (no tmp uploads folder yet) 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: ... can't check, you have no projects Redis version >= 2.8.0? ... yes Ruby version >= 2.5.3 ? ... yes (2.6.3) Git version >= 2.22.0 ? ... yes (2.24.1) Git user has default SSH configuration? ... yes Active users: ... 1 Is authorized keys file accessible? ... yes Elasticsearch version 5.6 - 6.x? ... skipped (elasticsearch is disabled)

Checking GitLab App ... Finished

Checking GitLab subtasks ... Finished

Edited by lixiranqq