OpenIDConnect - unable to get local issuer certificate
Summary
After installing GitLab CE (using Docker container) I'm unable to setup a OpenIDConnect connection between GitLab and (in this case Keycloak) when Keycloak is using a self-signed internal certificate. I have added the CA file to the Docker container under /etc/gitlab/trusted-certs/ca.crt.
Steps to reproduce
On the Login screen of GitLab click on the OpenID button. After clicking the button, a http 500 error is reported. Relevant log details are mentioned below.
What is the current bug behavior?
User is not redirected to the Keycloak login page, but receives a http 500 error.
What is the expected correct behavior?
User should be redirected to the Keycloak login page so the user can enter there login credentials there and can be redirected back to GitLab (where the user is then logged in)
Relevant logs and/or screenshots
Recipe: gitlab::add_trusted_certs
* directory[/etc/gitlab/trusted-certs] action create (up to date)
* directory[/opt/gitlab/embedded/ssl/certs] action create (up to date)
* file[/opt/gitlab/embedded/ssl/certs/README] action create
- create new file /opt/gitlab/embedded/ssl/certs/README
- update content in file /opt/gitlab/embedded/ssl/certs/README from none to 623059
--- /opt/gitlab/embedded/ssl/certs/README 2021-10-28 07:06:21.757764974 +0000
+++ /opt/gitlab/embedded/ssl/certs/.chef-README20211028-31-mdb1j3 2021-10-28 07:06:21.756764973 +0000
@@ -1 +1,4 @@
+This directory is managed by omnibus-gitlab.
+ Any file placed in this directory will be ignored
+. Place certificates in /etc/gitlab/trusted-certs.
- change mode from '' to '0644'
* ruby_block[Move existing certs and link to /opt/gitlab/embedded/ssl/certs] action run
* Moving existing certificates found in /opt/gitlab/embedded/ssl/certs
* Symlinking existing certificates found in /etc/gitlab/trusted-certs
Linking 3a9e18b5.0 from /etc/gitlab/trusted-certs/ca.crt
Output of checks
Results of GitLab environment info
gitlab_rails['omniauth_providers'] = [
{ 'name' => 'openid_connect',
'label' => 'Keycloak',
'args' => {
'name' => 'openid_connect',
'scope' => ['openid','profile'],
'response_type' => 'code',
'issuer' => 'https://keycloak/auth/realms/master',
'discovery' => true,
'client_auth_method' => 'query',
'send_scope_to_token_endpoint' => 'false',
'client_options' => {
'identifier' => '-some-clientid-',
'secret' => '-some-guid-secret-',
'redirect_uri' => 'https://test.host/gitlab/users/auth/openid_connect/callback'
}
}
}
]
gitlab-rake gitlab:env:info
``` gitlab-rake gitlab:env:info System information System: Current User: git Using RVM: no Ruby Version: 2.7.4p191 Gem Version: 3.1.4 Bundler Version:2.1.4 Rake Version: 13.0.6 Redis Version: 6.0.14 Git Version: 2.33.0. Sidekiq Version:6.2.2 Go Version: unknown GitLab information Version: 14.4.0 Revision: 51b27ab5805 Directory: /opt/gitlab/embedded/service/gitlab-rails DB Adapter: PostgreSQL DB Version: 12.7 URL: https://factory-1.vagrant/gitlab HTTP Clone URL: https://factory-1.vagrant/gitlab/some-group/some-project.git SSH Clone URL: ssh://git@factory-1.vagrant:2289/some-group/some-project.git Using LDAP: no Using Omniauth: yes Omniauth Providers: openid_connect GitLab Shell Version: 13.21.1 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
GitLab version: 14.4.0-ce.0 Type: Docker container using omnibus
gitlab-rake gitlab:check SANITIZE=true
root@13b954503a82:/# gitlab-rake gitlab:check SANITIZE=true Checking GitLab subtasks ... Checking GitLab Shell ... GitLab Shell: ... GitLab Shell version >= 13.21.1 ? ... OK (13.21.1) 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: ... 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 >= 5.0.0? ... yes Ruby version >= 2.7.2 ? ... yes (2.7.4) Git version >= 2.33.0 ? ... yes (2.33.0) Git user has default SSH configuration? ... yes Active users: ... 0 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
GitLab should use the CA files stored in /etc/gitlab/trusted-certs/ for all components to selfsigned or private CA's can be used for OpenIDConnect login.