相关文章推荐
细心的拖把  ·  GitLab container ...·  1 月前    · 
腹黑的开心果  ·  JdbcTemplate ...·  1 年前    · 
千杯不醉的牙膏  ·  TreeView 概述 - WPF ...·  1 年前    · 
耍酷的炒饭  ·  What is the windows ...·  2 年前    · 
  • Useful OpenSSL Debugging Commands
  • Common SSL errors
  • Git-LFS and other embedded services written in golang report custom certificate signed by unknown authority
  • Reconfigure Fails Due to Certificates
  • Custom Certificates Missing or Skipped
  • Custom certificates not detected
  • Let’s Encrypt Certificate signed by unknown authority
  • Let’s Encrypt fails on reconfigure
  • Using an internal CA certificate with GitLab
  • X.509 key values mismatch error
  • Using GitLab Runner with a GitLab instance configured with internal CA certificate or self-signed certificate
  • Mirroring a remote GitLab repository that uses a self-signed SSL certificate
  • Unable to perform Git operations due to an internal or self-signed certificate
  • SSL_connect wrong version number
  • schannel: SEC_E_UNTRUSTED_ROOT
  • Troubleshooting SSL

    This page contains a list of common SSL-related errors and scenarios that you may encounter while working with GitLab. It should serve as an addition to the main SSL documentation:

    Useful OpenSSL Debugging Commands

    Sometimes it’s helpful to get a better picture of the SSL certificate chain by viewing it directly at the source. These commands are part of the standard OpenSSL library of tools for diagnostics and debugging.

    note
    GitLab includes its own custom-compiled version of OpenSSL that all GitLab libraries are linked against. It’s important to run the following commands using this OpenSSL version.

      Perform a test connection to the host over HTTPS. Replace HOSTNAME with your GitLab URL (excluding HTTPS), and replace port with the port that serves HTTPS connections (usually 443):

      echo | /opt/gitlab/embedded/bin/openssl s_client -connect HOSTNAME:port
      

      The echo command sends a null request to the server, causing it to close the connection rather than wait for additional input. You can use the same command to test remote hosts (for example, a server hosting an external repository), by replacing HOSTNAME:port with the remote host’s domain and port number.

      This command’s output shows you the certificate chain, any public certificates the server presents, along with validation or connection errors if they occur. This makes for a quick check for any immediate issues with your SSL settings.

    • View a certificate’s details in text form using x509 . Be sure to replace /path/to/certificate.crt with the certificate’s path:

      /opt/gitlab/embedded/bin/openssl x509 -in /path/to/certificate.crt -text -noout
      

      For example, GitLab automatically fetches and places certificates acquired from Let’s Encrypt at /etc/gitlab/ssl/hostname.crt . You can use the x509 command with that path to quickly display the certificate’s information (for example, the hostname, issuer, validity period, and more).

      If there’s a problem with the certificate, an error occurs .

    • Fetch a certificate from a server and decode it. This combines both of the above commands to fetch the server’s SSL certificate and decode it to text:

      echo | /opt/gitlab/embedded/bin/openssl s_client -connect HOSTNAME:port | /opt/gitlab/embedded/bin/openssl x509 -text -noout
      

    Common SSL errors

    SSL certificate problem: unable to get local issuer certificate

    This error indicates the client cannot get the root CA. To fix this, you can either trust the root CA of the server you are trying to connect to on the client or modify the certificate to present the full chained certificate on the server you are trying to connect to.

    note
    It is recommended to use the full certificate chain in order to prevent SSL errors when clients connect. The full certificate chain order should consist of the server certificate first, followed by all intermediate certificates, with the root CA last.
  • unable to verify the first certificate

    This error indicates that an incomplete certificate chain is being presented by the server. To fix this error, you will need to replace server’s certificate with the full chained certificate . The full certificate chain order should consist of the server certificate first, followed by all intermediate certificates, with the root CA last.

  • certificate signed by unknown authority

    This error indicates that the client does not trust the certificate or CA. To fix this error, the client connecting to server will need to trust the certificate or CA .

  • SSL certificate problem: self signed certificate in certificate chain

    This error indicates that the client does not trust the certificate or CA. To fix this error, the client connecting to server will need to trust the certificate or CA .

  • x509: certificate relies on legacy Common Name field, use SANs instead

    This error indicates that SANs (subjectAltName) must be configured in the certificate. For more information, see this issue .

  • Git-LFS and other embedded services written in golang report custom certificate signed by unknown authority note

    The gitlab-workhorse and other services written in golang use the crypto/tls library from golang instead of OpenSSL .

    Add the following entry in /etc/gitlab/gitlab.rb to work around the issue as reported :

    gitlab_workhorse['env'] = {
      'SSL_CERT_DIR' => '/opt/gitlab/embedded/ssl/certs/'
    note
    If you have installed GitLab to a path other than /opt/gitlab/ then modify the entry above with the correct path in your operating environment.

    Reconfigure Fails Due to Certificates

    Check /opt/gitlab/embedded/ssl/certs and remove any files other than README.md that aren’t valid X.509 certificates.

    Custom Certificates Missing or Skipped

    GitLab versions 8.9.0 , 8.9.1 , and 8.9.2 all mistakenly used the /etc/gitlab/ssl/trusted-certs/ directory. This directory is safe to remove if it is empty. If it still contains custom certificates then move them to /etc/gitlab/trusted-certs/ and run gitlab-ctl reconfigure .

    If no symlinks are created in /opt/gitlab/embedded/ssl/certs/ and you see the message “Skipping cert.pem ” after running gitlab-ctl reconfigure , that means there may be one of four issues:

    1. The file in /etc/gitlab/trusted-certs/ is a symlink
    2. The file is not a valid PEM or DER-encoded certificate
    3. Perl is not installed on the operating system which is needed for c_rehash to properly symlink certificates
    4. The certificate contains the string TRUSTED

    Test the certificate’s validity using the commands below:

    Invalid certificate files produce the following output:

    To test if c_rehash is not symlinking the certificate due to a missing perl interpreter:

    If you see this message, you will need to install perl with your distribution’s package manager.

    If you inspect the certificate itself, then look for the string TRUSTED :

    If it does, like the example above, then try removing the string TRUSTED and running gitlab-ctl reconfigure again.

    Custom certificates not detected

    If after running gitlab-ctl reconfigure :

    1. no symlinks are created in /opt/gitlab/embedded/ssl/certs/ ;
    2. you have placed custom certificates in /etc/gitlab/trusted-certs/ ; and
    3. you do not see any skipped or symlinked custom certificate messages

    You may be encountering an issue where Omnibus GitLab thinks that the custom certificates have already been added.

    To resolve, delete the trusted certificates directory hash:

    Then run gitlab-ctl reconfigure again. The reconfigure should now detect and symlink your custom certificates.

    Let’s Encrypt Certificate signed by unknown authority

    The initial implementation of Let’s Encrypt integration only used the certificate, not the full certificate chain.

    Starting in 10.5.4, the full certificate chain will be used. For installs which are already using a certificate, the switchover will not happen until the renewal logic indicates the certificate is near expiration. To force it sooner, run the following

    Where HOSTNAME is the hostname of the certificate.

    Let’s Encrypt fails on reconfigure

    When you reconfigure, there are common scenarios under which Let’s Encrypt may fail:

      Let’s Encrypt may fail if your server isn’t able to reach the Let’s Encrypt verification servers or vice versa:

      letsencrypt_certificate[gitlab.domain.com] (letsencrypt::http_authorization line 3) had an error: RuntimeError: acme_certificate[staging]  (/opt/gitlab/embedded/cookbooks/cache/cookbooks/letsencrypt/resources/certificate.rb line 20) had an error: RuntimeError: [gitlab.domain.com] Validation failed for domain gitlab.domain.com
      

      If you run into issues reconfiguring GitLab due to Let’s Encrypt make sure you have ports 80 and 443 open and accessible .

    1. Your domain’s Certification Authority Authorization (CAA) record does not allow Let’s Encrypt to issue a certificate for your domain. Look for the following error in the reconfigure output:

      letsencrypt_certificate[gitlab.domain.net] (letsencrypt::http_authorization line 5) had an error: RuntimeError: acme_certificate[staging]   (/opt/gitlab/embedded/cookbooks/cache/cookbooks/letsencrypt/resources/certificate.rb line 25) had an error: RuntimeError: ruby_block[create certificate for gitlab.domain.net] (/opt/gitlab/embedded/cookbooks/cache/cookbooks/acme/resources/certificate.rb line 108) had an error: RuntimeError: [gitlab.domain.com] Validation failed, unable to request certificate
      

      If you’re using a test domain such as gitlab.example.com, without a certificate, you’ll see the unable to request certificate error shown above. In that case, disable Let’s Encrypt by setting letsencrypt['enable'] = false in /etc/gitlab/gitlab.rb.

    You can test your domain using the Let’s Debug diagnostic tool. It can help you figure out why you can’t issue a Let’s Encrypt certificate.

    Using an internal CA certificate with GitLab

    After configuring a GitLab instance with an internal CA certificate, you might not be able to access it by using various CLI tools. You may experience the following issues:

    If you have the previously described issues, add your certificate to /etc/gitlab/trusted-certs , and then run sudo gitlab-ctl reconfigure .

    X.509 key values mismatch error

    After configuring your instance with a certificate bundle, NGINX may display the following error message:

    SSL: error:0B080074:x509 certificate routines:X509_check_private_key:key values mismatch

    This error message means that the server certificate and key you have provided don’t match. You can confirm this by running the following command and then comparing the output:

    The following is an example of an md5 output between a matching key and certificate. Note the matching md5 hashes:

    This is an opposing output with a non-matching key and certificate which shows different md5 hashes:

    If the two outputs differ like the previous example, there’s a mismatch between the certificate and key. Contact the provider of the SSL certificate for further support.

    Using GitLab Runner with a GitLab instance configured with internal CA certificate or self-signed certificate

    Besides getting the errors mentioned in Using an internal CA certificate with GitLab , your CI pipelines may get stuck in Pending status. In the runner logs you may see the following error message:

    Dec  6 02:43:17 runner-host01 gitlab-runner[15131]: #033[0;33mWARNING: Checking for jobs... failed
    #033[0;m  #033[0;33mrunner#033[0;m=Bfkz1fyb #033[0;33mstatus#033[0;m=couldn't execute POST against
    https://gitlab.domain.tld/api/v4/jobs/request: Post https://gitlab.domain.tld/api/v4/jobs/request:
    x509: certificate signed by unknown authority
    

    Follow the details in Self-signed certificates or custom Certification Authorities for GitLab Runner .

    Mirroring a remote GitLab repository that uses a self-signed SSL certificate

    When configuring a local GitLab instance to mirror a repository from a remote GitLab instance that uses a self-signed certificate, you may see the SSL certificate problem: self signed certificate error message in the user interface.

    The cause of the issue can be confirmed by checking if:

      curl fails:

      $ curl "https://gitlab.domain.tld"
      curl: (60) SSL certificate problem: self signed certificate
      More details here: https://curl.haxx.se/docs/sslcerts.html
      

      Testing by using the Rails console also fails:

      uri = URI.parse("https://gitlab.domain.tld")
      http = Net::HTTP.new(uri.host, uri.port)
      http.use_ssl = true
      http.verify_mode = 1
      response = http.request(Net::HTTP::Get.new(uri.request_uri))
      Traceback (most recent call last):
            1: from (irb):5
      OpenSSL::SSL::SSLError (SSL_connect returned=1 errno=0 state=error: certificate verify failed (unable to get local issuer certificate))
      

    To fix this problem:

    You may also get another error message when trying to mirror a repository from a remote GitLab instance that uses a self-signed certificate:

    2:Fetching remote upstream failed: fatal: unable to access 'https://gitlab.domain.tld/root/test-repo/':
    SSL: unable to obtain common name from peer certificate
    

    In this case, the problem can be related to the certificate itself:

    1. Validate that your self-signed certificate isn’t missing a common name. If it is, regenerate a valid certificate
    2. Add the certificate to /etc/gitlab/trusted-certs .
    3. Run sudo gitlab-ctl reconfigure .

    Unable to perform Git operations due to an internal or self-signed certificate

    If your GitLab instance is using a self-signed certificate, or if the certificate is signed by an internal certificate authority (CA), you might experience the following errors when attempting to perform Git operations:

    To fix this problem:

    SSL_connect wrong version number

    A misconfiguration may result in:

    Some of these errors come from the Excon Ruby gem, and could be generated in circumstances where GitLab is configured to initiate an HTTPS session to a remote server that is serving only HTTP.

    One scenario is that you’re using object storage , which isn’t served under HTTPS. GitLab is misconfigured and attempts a TLS handshake, but the object storage responds with plain HTTP.

    schannel: SEC_E_UNTRUSTED_ROOT

    If you’re on Windows and get the following error:

    You must specify that Git should use OpenSSL:

    Alternatively, you can ignore SSL verification by running:

    caution
    Proceed with caution when ignoring SSL due to the potential security issues associated with disabling this option at global level. Use this option only when troubleshooting, and reinstate SSL verification immediately after.
    git config --global http.sslVerify false
    

    Docs

    Edit this page to fix an error or add an improvement in a merge request.
    Create an issue to suggest an improvement to this page.

    Product

    Create an issue if there's something you don't like about this feature.
    Propose functionality by submitting a feature request.
    Join First Look to help shape new features.

    Feature availability and product trials

    View pricing to see all GitLab tiers and features, or to upgrade.
    Try GitLab for free with access to all features for 30 days.

    Get Help

    If you didn't find what you were looking for, search the docs.
    If you want help with something specific and could use community support, post on the GitLab forum.
    For problems setting up or using this feature (depending on your GitLab subscription).

    Request support