SSO fails with SSL client certificates enabled
Summary
If Gitlab is using HTTPS with client certificates, SSO between Mattermost and GItlab fails with "Bad token request".
Steps to reproduce
I am using the latest versions of Gitlab-omnibus (8.12.7) and Mattermost-omnibus (3.4.0) and I am running them on two different machines. Enable HTTPS in Gitlab. Enable SSL clients certificates in Gitlab. Configure both of them for SSO. Try to login from Mattermost using SSO with Gitlab.
Expected behavior
Sign in should succeed.
Observed behavior
When enabling SSL client certificates in Gitlab and trying to sign into Mattermost using SSO, I get a "Bad token request" and sign in fails. The Mattermost log shows only the following with the details section empty:
[EROR] /signup/gitlab/complete:AuthorizeOAuthUser code=500 rid=1pk6mwjxzibc7dnpyt6zr6eugc uid= ip=xxx.xxx.xxx.xxx Bad response from token request [details: ]
Possible fixes
Mattermost config file should have an option pointing to where the client certificate is stored and use it during the token exchange.