Skip to content
Snippets Groups Projects

Add support for using HTTP TLS client cert

Merged Stan Hu requested to merge sh-support-mutual-tls-http-client into master
All threads resolved!

What does this MR do?

Some customers need to configure mutual TLS authentication for Webhooks. This commit adds support for an instance-wide client certificate via two settings added in gitlab!140263 (merged):

gitlab_rails['http_client']['tls_client_cert_file'] = '/path/to/cert.pem'
gitlab_rails['http_client']['tls_client_cert_password'] = 'somepassword'

Related issues

How to set up and validate locally

You can test mutual TLS authentication via https://client.badssl.com/:

  1. Run gitlab-rails console.
  2. Run ::Gitlab::HTTP_V2.get('https://client.badssl.com'). This should fail:
irb(main):001:0> ::Gitlab::HTTP_V2.get('https://client.badssl.com')
=>
"<html>\r\n" +
"<head><title>400 No required SSL certificate was sent</title></head>\r\n" +
"<body bgcolor=\"white\">\r\n" +
"<center><h1>400 Bad Request</h1></center>\r\n" +
"<center>No required SSL certificate was sent</center>\r\n" +
"<hr><center>nginx/1.10.3 (Ubuntu)</center>\r\n" +
"</body>\r\n" +
"</html>\r\n"
  1. Download the client cert: curl -o /tmp/badssl.com-client.pem https://badssl.com/certs/badssl.com-client.pem
  2. In /etc/gitlab/gitlab.rb, add:
gitlab_rails['http_client']['tls_client_cert_file'] = '/tmp/badssl.com-client.pem'
gitlab_rails['http_client']['tls_client_cert_password'] = 'badssl.com'
  1. Run gitlab-ctl reconfigure.
  2. Repeat steps 1 and 2 again. This should succeed:
irb(main):001:0> ::Gitlab::HTTP_V2.get('https://client.badssl.com')
=>
"<!DOCTYPE html>\n" +
"<html>\n" +
"<head>\n" +
"  <meta charset=\"utf-8\">\n" +
"  <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n" +
"  <link rel=\"shortcut icon\" href=\"/icons/favicon-green.ico\"/>\n" +
"  <link rel=\"apple-touch-icon\" href=\"/icons/icon-green.png\"/>\n" +
"  <title>client.badssl.com</title>\n" +
"  <link rel=\"stylesheet\" href=\"/style.css\">\n" +
"  <style>body { background: green; }</style>\n" +
"</head>\n" +
"<body>\n" +
"<div id=\"content\">\n" +
"  <h1 style=\"font-size: 12vw;\">\n" +
"    client.<br>badssl.com\n" +
"  </h1>\n" +
"</div>\n" +
"\n" +
"<div id=\"footer\">\n" +
"  This site requires a <a href=\"https://en.wikipedia.org/wiki/Transport_Layer_Security#Client-authenticated_TLS_handshake\">client-authenticated</a> TLS handshake.\n" +
"</div>\n" +
"\n" +
"</body>\n" +
"</html>\n"

Checklist

See Definition of done.

For anything in this list which will not be completed, please provide a reason in the MR discussion.

Required

  • MR title and description are up to date, accurate, and descriptive.
  • MR targeting the appropriate branch.
  • Latest Merge Result pipeline is green.
  • When ready for review, MR is labeled "~workflow::ready for review" per the Distribution MR workflow.

For GitLab team members

If you don't have access to this, the reviewer should trigger these jobs for you during the review process.

  • The manual Trigger:ee-package jobs have a green pipeline running against latest commit.
  • If config/software or config/patches directories are changed, make sure the build-package-on-all-os job within the Trigger:ee-package downstream pipeline succeeded.
  • If you are changing anything SSL related, then the Trigger:package:fips manual job within the Trigger:ee-package downstream pipeline must succeed.
  • If CI configuration is changed, the branch must be pushed to dev.gitlab.org to confirm regular branch builds aren't broken.

Expected (please provide an explanation if not completing)

  • Test plan indicating conditions for success has been posted and passes.
  • Documentation created/updated.
  • Tests added.
  • Integration tests added to GitLab QA.
  • Equivalent MR/issue for the GitLab Chart opened.
  • Validate potential values for new configuration settings. Formats such as integer 10, duration 10s, URI scheme://user:passwd@host:port may require quotation or other special handling when rendered in a template and written to a configuration file.
Edited by Stan Hu

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Stan Hu mentioned in merge request gitlab!142510 (merged)

    mentioned in merge request gitlab!142510 (merged)

  • Stan Hu added 33 commits

    added 33 commits

    Compare with previous version

  • Stan Hu requested review from @clemensbeck

    requested review from @clemensbeck

  • Contributor

    E2E Test Result Summary

    allure-report-publisher generated test report!

    qa-subset-test: :x: test report for 0c843ba4

    expand test summary
    +---------------------------------------------------------------------+
    |                           suites summary                            |
    +----------------+--------+--------+---------+-------+-------+--------+
    |                | passed | failed | skipped | flaky | total | result |
    +----------------+--------+--------+---------+-------+-------+--------+
    | Data Stores    | 93     | 0      | 3       | 0     | 96    | ✅     |
    | Package        | 172    | 0      | 3       | 0     | 175   | ✅     |
    | Create         | 195    | 1      | 24      | 0     | 220   | ❌     |
    | Release        | 15     | 0      | 0       | 0     | 15    | ✅     |
    | Govern         | 155    | 0      | 4       | 0     | 159   | ✅     |
    | Plan           | 163    | 0      | 1       | 0     | 164   | ✅     |
    | Systems        | 8      | 0      | 0       | 0     | 8     | ✅     |
    | Verify         | 93     | 0      | 0       | 0     | 93    | ✅     |
    | GitLab Metrics | 2      | 0      | 1       | 0     | 3     | ✅     |
    | Manage         | 2      | 0      | 0       | 0     | 2     | ✅     |
    | Configure      | 1      | 0      | 0       | 0     | 1     | ✅     |
    | Monitor        | 25     | 0      | 1       | 0     | 26    | ✅     |
    | Analytics      | 3      | 0      | 0       | 0     | 3     | ✅     |
    +----------------+--------+--------+---------+-------+-------+--------+
    | Total          | 927    | 1      | 37      | 0     | 965   | ❌     |
    +----------------+--------+--------+---------+-------+-------+--------+
  • Clemens Beck resolved all threads

    resolved all threads

  • Clemens Beck approved this merge request

    approved this merge request

  • :white_check_mark: Test plan passed in a local Docker environment.

  • Clemens Beck requested review from @apatterson2

    requested review from @apatterson2

  • LGTM (with possible exception of documentation nit).

  • Stan Hu added 1 commit

    added 1 commit

    • 0c843ba4 - Improve gitlab.rb.template comment for mutual TLS section

    Compare with previous version

  • Andrew Patterson resolved all threads

    resolved all threads

  • Andrew Patterson approved this merge request

    approved this merge request

  • @balasankarc Would you please merge this MR? I do not have permissions.

  • requested review from @balasankarc

  • Andrew Patterson removed review request for @apatterson2

    removed review request for @apatterson2

  • Balasankar 'Balu' C approved this merge request

    approved this merge request

  • Balasankar 'Balu' C enabled an automatic merge when the pipeline for f2f4fe5a succeeds

    enabled an automatic merge when the pipeline for f2f4fe5a succeeds

  • mentioned in commit eeb43658

  • added workflowstaging label and removed workflowcanary label

  • Stan Hu mentioned in commit gitlab@15680b0c

    mentioned in commit gitlab@15680b0c

  • Stan Hu mentioned in merge request gitlab!143115 (merged)

    mentioned in merge request gitlab!143115 (merged)

  • Stan Hu mentioned in commit gitlab@204ed47e

    mentioned in commit gitlab@204ed47e

  • Stan Hu mentioned in commit gitlab@34782cdd

    mentioned in commit gitlab@34782cdd

  • Stan Hu mentioned in commit gitlab@286493c2

    mentioned in commit gitlab@286493c2

  • Stan Hu mentioned in commit gitlab@556a5f9e

    mentioned in commit gitlab@556a5f9e

  • Please register or sign in to reply
    Loading