You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Skip certificate warning, using internal enterprise CA "certificate signed by unknown authority" #1735
authrelated to tokens, authentication state, or oauthcoreThis issue is not accepting PRs from outside contributorsenhancementa request to improve CLIneeds-investigationCLI team needs to investigatepitchpitched internally for prioritisation
I expect I can bypass "gh" the unknown authority warning, with some command line arg like a "curl -k" to just skip the TLS verification.
Logs
Paste the activity from your command line. Redact if needed.
Reacted by Nate Smith, Keith Devens, Liron Shimrony, Frater.nul, Santiago Cardin, Sjors Gielen, Paul Anton Letnes, Gábor Pichner, JuanSe Botello Hu., Niko Eckerskorn and 9 more
@ericcurtin Thank you for reporting! What format are your custom certificates in? To cover use-cases like this, we should allow a configuration option to read a custom certificate, likely from disk, when establishing connection to a GHE server.
Ideally, gh would just pick up certificate from your system's Keychain store, but I'm not sure if it's feasible to build cross-platform support for this.
We won't be adding an option to skip certificate verification because that would be insecure and would defeat the point of SSL and certificates being enforced in the first place.
I was actually able to solve my problem on a macOS. The problem was not really on GitHub cli, rather how Go trusts (or not) the certs available.
In my case, I had to go to Keychain Access and find the root/intermediate certificate used to sign my GHE server. Once I found it, double clicked, expanded the Trust section and selected to "When using this certificate: Always Trust". Probably trusting certs on your OS cert store is the way to go.
Same problem, mainly posting because this also applies to web-based login:
$ gh auth login
? What account do you want to log into? GitHub Enterprise Server
? GHE hostname: github.mycompany.corp
- Logging into github.mycompany.corp
? How would you like to authenticate? Login with a web browser
failed to authenticate via web browser: Post "https://github.mycompany.corp/login/device/code": x509: certificate signed by unknown authority
Chrome can let me proceed when I view the web interface (which is only accessible on our VPN anyway). It'd be nice if gh would allow that too.
If the official solution is "you need to add the cert to your system keychain" it'd be nice if there was something in the docs.
@mislav SSL is no longer considered a secure protocol, but I'm sure you mean TLS :) From an encryption perspective as your data is still encrypted, saying it defeats the purpose of TLS seems extreme. But it does mean you have not configured your system to add this certificate authority as a trusted one, which would be better practice to be sure no-one is pretending to be the host. This is why git, curl, wget, chrome, firefox, edge, etc. all provide ways to bypass this
My gut reaction was that a -k was a natural addition given that other tools support it; I would also agree that it doesn't "defeat" the purpose of TLS. Supporting self-signed certs in enclosed network environments is something I've definitely made explicitly available for users of enterprise software at past jobs.
That said, I'm no expert and wouldn't feel comfortable making a final call here.
This is also challenging from a troubleshooting perspective as valid certificates may not always be readily available for test systems, etc... It would be highly beneficial to be able to bypass this check with a config option/flag.
Being able to specify the ca-cert file to use when talking to the Enterprise server would be sufficient in many cases and would mean you don't have to ignore the certificate. e.g. curl --cacert ~/.ssh/chain.crt
> cat | gh auth login --with-token
ghp_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
* Request at 2025-08-07 21:36:09.054536941 +0200 CEST m=+0.046441632
* Request to https://api.github.com/
* tls: failed to verify certificate: x509: certificate signed by unknown authority
* Request took 96.23556ms
error validating token: Get "https://api.github.com/": tls: failed to verify certificate: x509: certificate signed by unknown authority
It seems that the required trusted certificate is missing. However, I am not an admin user on this linux server, and can't change global certificate stores...
This is what I tried:
echo"aaa"| openssl s_client -connect api.github.com:443 -proxy XXXX:0000 -showcerts > github.crt
# manually removed some noise from github.crt, so that it looks like this:## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# // i:C = GB, ST = Greater Manchester, L = Salford, O = Sectigo Limited, CN = Sectigo ECC Domain Validation Secure Server CA# -----BEGIN CERTIFICATE-----# ...# KQIhAPkzw1jn3t/HCIVT98ZYrTYNsxElJRY6JH89pJlVt3Ay# -----END CERTIFICATE-----## // i:C = US, ST = New Jersey, L = Jersey City, O = The USERTRUST Network, CN = USERTrust ECC Certification Authority# -----BEGIN CERTIFICATE-----# ...# 4ToKFbZl+/OnFFzqnvOhcjHvClECEQcKmc8fmA==# -----END CERTIFICATE-----## // i:C = GB, ST = Greater Manchester, L = Salford, O = Comodo CA Limited, CN = AAA Certificate Services# -----BEGIN CERTIFICATE-----# ...# 8qn0dNW44bOwgeThpWOjzOoEeJBuv/c=# -----END CERTIFICATE-----# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~export SSL_CERT_FILE=/path/to/github.crt
I checked with strace, and it seems that gh opens my github.crt file, as well as a bunch of other crt files on the machine. However, it made absolutely no difference, I am still getting the same error. 😡
Is there any working way to pass my own list of CA certs to gh ???? I am using gh version 2.76.2 (2025-07-30). If not, and there is no option to skip cert verification, then gh is useless in my case...
This is an interesting discussion, and thanks everyone for sharing their thoughts! 🍻
Note
This is rather old issue, and the maintainers who triaged this at the time are no longer working on gh. So, apologies for the delayed response. 🙏
Here are my two cents on this. Please note that I'm not confirming any approach/solution here. It's a just part of the discussion to understand what our community needs, and what we can actually do.
First, I think I agree with @vilmibm that it's okay to introduce a feature to help with this issue. Unless it's not a default behaviour, it's not a security flaw and is a legit ergonomics enhancement.
Although an all-encompassing solution (i.e. fixing the pain on all HTTP(S) clients) is to add the certs to your local machine trusted certs, I can see this might not be an option for everyone. Mostly for people who do not have root access, or test environments with limited access.
Warning
Needless to say that gh could potentially provide is not going to help with the browser warnings, and that's out of scope.
--option vs env vars
Before jumping to potential solutions, I want to make a point against ideas like adding a --cert or -k option. There are two reasons that this is not a good solution:
Almost all gh commands interact with the GitHub API over HTTPS requests. If we want to go with a --cert or -k option, that means we have to add them to all gh commands. In other words anything regarding the HTTP communication mechanics is actually a cross-cutting concern, and it's not really efficient to deal with CCC on a case-by-case basis. It'd be a huge change, and increasingly hard to maintain down the road.
gh and its extensions use cli/go-gh as a thin wrapper around the GitHub API. The only way for communicating options to cli/go-gh, so that gh and its extensions both can be affected is via environment variables. In other words, there is no way to have a -k or --cert option at the gh level that can be certainly applied to the extensions. This is really a hard constraint.
Ignoring the above points, using --cert or -k options can soon be a headache for users who are scripting against both already trusted hostnames (e.g. github.com) and custom hostnames. I mean they would have to change their command structure based on the host/cert, and their efforts might be less reusable or more prone to errors.
So, regardless of the details, any configuration has to happen over env vars.
Suggestions
I can summarise the discussion here in two independent approaches; disabling hostname verification, and/or allowing custom certs. These are not mutually exclusive so we can even consider both at the end.
Disabling hostname verification: we can have an env var like GH_INSECURE or GH_DISABLE_TLS_VERIFICATION, and when it's set gh (actually cli/go-gh) must disable the hostname verification.
Allowing custom certs: this can be and env var like GH_CERT_PATH or GH_CERTS that points to a file or a directory. gh (actually cli/go-gh) should pick up the certs from the given path and populate a CertPool when creating HTTP clients.
As I mentioned earlier, this is the responsibility of cli/go-gh to support above cases. When it's updated, new gh releases and the new releases of gh extensions (those who also upgrade their cli/go-gh dependency) will benefit from it.
First, thanks for the detailed review. I have some questions:
I understand why command line parameters for each command are out of the question, but environment variables could be a bit of a pain to maintain in dynamically configurable environments... Could you consider the following approaches:
Storing them once in gh config set ?
I understand that some connection-specific parameters can be added during gh auth login. And then they are used automatically while this authentication config is selected. Can this be used here as well?
Does a new ticket have to be created in cli/go-gh to proceed, or this discussion is enough?
What's confusing me a bit is that as a Go tool, this should automatically support SSL_CERT_FILE, but gh-cli doesn't seem to. Is this default behavior being intentionally disabled?
Cross-posting from #13676 (closed as a dup) at @babakks's suggestion — adding the macOS/trustd angle, which also answers @rnapier's question about SSL_CERT_FILE, since that's really the crux here.
Why SSL_CERT_FILE doesn't "just work": on Linux, Go's crypto/x509 builds its roots from files and honors SSL_CERT_FILE/SSL_CERT_DIR, so it works transparently. On macOS, when tls.Config.RootCAs is nil, Go defers verification to the system trust evaluator (Security.framework, backed by the trustd mach service) rather than a file-based pool — so the SSL_CERT_FILE escape hatch that works on Linux isn't honored for the default verification path. Two failure modes fall out of this same gap:
Internal/enterprise CA not in the system keychain → certificate signed by unknown authority (this issue: Zscaler, corporate CAs, GHE behind a private CA).
trustd unreachable — in some sandboxed environments the mach service is blocked, so everygh HTTPS call fails with no way to supply a CA bundle.
A small fix that covers both: at startup, if SSL_CERT_FILE (or a GH_-prefixed variant) is set, load the PEM into an x509.CertPool and set it as RootCAs on a clone of http.DefaultTransport. A non-nil RootCAs forces Go's own pure-Go verifier, bypassing trustd entirely. It's a no-op when unset, and since go-gh's api.NewHTTPClient bases its transport on http.DefaultTransport, every client (REST, GraphQL, auth) inherits it.
We've been running this in a fork as a single ~40-line init(): rexovasgroup#51. Happy to open a PR upstream if an SSL_CERT_FILE-based approach sounds acceptable.
authrelated to tokens, authentication state, or oauthcoreThis issue is not accepting PRs from outside contributorsenhancementa request to improve CLIneeds-investigationCLI team needs to investigatepitchpitched internally for prioritisation
Activity
mislav commentedon Sep 17, 2020
@ericcurtin Thank you for reporting! What format are your custom certificates in? To cover use-cases like this, we should allow a configuration option to read a custom certificate, likely from disk, when establishing connection to a GHE server.
Ideally, gh would just pick up certificate from your system's Keychain store, but I'm not sure if it's feasible to build cross-platform support for this.
We won't be adding an option to skip certificate verification because that would be insecure and would defeat the point of SSL and certificates being enforced in the first place.
tyron commentedon Sep 17, 2020
I was actually able to solve my problem on a macOS. The problem was not really on GitHub cli, rather how Go trusts (or not) the certs available.
In my case, I had to go to Keychain Access and find the root/intermediate certificate used to sign my GHE server. Once I found it, double clicked, expanded the Trust section and selected to "When using this certificate: Always Trust". Probably trusting certs on your OS cert store is the way to go.
Related to golang/go#24652 (comment)
kbd commentedon Sep 17, 2020
Same problem, mainly posting because this also applies to web-based login:
Chrome can let me proceed when I view the web interface (which is only accessible on our VPN anyway). It'd be nice if
ghwould allow that too.If the official solution is "you need to add the cert to your system keychain" it'd be nice if there was something in the docs.
ericcurtin commentedon Sep 17, 2020
@mislav SSL is no longer considered a secure protocol, but I'm sure you mean TLS :) From an encryption perspective as your data is still encrypted, saying it defeats the purpose of TLS seems extreme. But it does mean you have not configured your system to add this certificate authority as a trusted one, which would be better practice to be sure no-one is pretending to be the host. This is why git, curl, wget, chrome, firefox, edge, etc. all provide ways to bypass this
ericcurtin commentedon Sep 18, 2020
Apologies for mislabeling as a bug also. This is certainly an enhancement @mislav
mislav commentedon Sep 18, 2020
@ericcurtin @kdb Fully agreed!
vilmibm commentedon Sep 18, 2020
My gut reaction was that a
-kwas a natural addition given that other tools support it; I would also agree that it doesn't "defeat" the purpose of TLS. Supporting self-signed certs in enclosed network environments is something I've definitely made explicitly available for users of enterprise software at past jobs.That said, I'm no expert and wouldn't feel comfortable making a final call here.
maclarel commentedon Sep 23, 2020
This is also challenging from a troubleshooting perspective as valid certificates may not always be readily available for test systems, etc... It would be highly beneficial to be able to bypass this check with a config option/flag.
8 remaining items
MartinLesterSynamedia commentedon Nov 14, 2022
Being able to specify the ca-cert file to use when talking to the Enterprise server would be sufficient in many cases and would mean you don't have to ignore the certificate. e.g.
curl --cacert ~/.ssh/chain.crtj-xella commentedon Aug 7, 2025
I am also having this issue:
It seems that the required trusted certificate is missing. However, I am not an admin user on this linux server, and can't change global certificate stores...
This is what I tried:
I checked with
strace, and it seems thatghopens mygithub.crtfile, as well as a bunch of other crt files on the machine. However, it made absolutely no difference, I am still getting the same error. 😡Is there any working way to pass my own list of CA certs to
gh???? I am usinggh version 2.76.2 (2025-07-30). If not, and there is no option to skip cert verification, thenghis useless in my case...daniel1941 commentedon Aug 8, 2025
Hi,
Any update on this? We're using GH from a corporate network with it's own certificate.
gh version 2.76.2 (2025-07-30)
babakks commentedon Aug 8, 2025
This is an interesting discussion, and thanks everyone for sharing their thoughts! 🍻
Note
This is rather old issue, and the maintainers who triaged this at the time are no longer working on
gh. So, apologies for the delayed response. 🙏Here are my two cents on this. Please note that I'm not confirming any approach/solution here. It's a just part of the discussion to understand what our community needs, and what we can actually do.
First, I think I agree with @vilmibm that it's okay to introduce a feature to help with this issue. Unless it's not a default behaviour, it's not a security flaw and is a legit ergonomics enhancement.
Although an all-encompassing solution (i.e. fixing the pain on all HTTP(S) clients) is to add the certs to your local machine trusted certs, I can see this might not be an option for everyone. Mostly for people who do not have root access, or test environments with limited access.
Warning
Needless to say that
ghcould potentially provide is not going to help with the browser warnings, and that's out of scope.--optionvs env varsBefore jumping to potential solutions, I want to make a point against ideas like adding a
--certor-koption. There are two reasons that this is not a good solution:Almost all
ghcommands interact with the GitHub API over HTTPS requests. If we want to go with a--certor-koption, that means we have to add them to allghcommands. In other words anything regarding the HTTP communication mechanics is actually a cross-cutting concern, and it's not really efficient to deal with CCC on a case-by-case basis. It'd be a huge change, and increasingly hard to maintain down the road.ghand its extensions usecli/go-ghas a thin wrapper around the GitHub API. The only way for communicating options tocli/go-gh, so thatghand its extensions both can be affected is via environment variables. In other words, there is no way to have a-kor--certoption at theghlevel that can be certainly applied to the extensions. This is really a hard constraint.Ignoring the above points, using
--certor-koptions can soon be a headache for users who are scripting against both already trusted hostnames (e.g.github.com) and custom hostnames. I mean they would have to change their command structure based on the host/cert, and their efforts might be less reusable or more prone to errors.So, regardless of the details, any configuration has to happen over env vars.
Suggestions
I can summarise the discussion here in two independent approaches; disabling hostname verification, and/or allowing custom certs. These are not mutually exclusive so we can even consider both at the end.
Disabling hostname verification: we can have an env var like
GH_INSECUREorGH_DISABLE_TLS_VERIFICATION, and when it's setgh(actuallycli/go-gh) must disable the hostname verification.Allowing custom certs: this can be and env var like
GH_CERT_PATHorGH_CERTSthat points to a file or a directory.gh(actuallycli/go-gh) should pick up the certs from the given path and populate aCertPoolwhen creating HTTP clients.As I mentioned earlier, this is the responsibility of
cli/go-ghto support above cases. When it's updated, newghreleases and the new releases ofghextensions (those who also upgrade theircli/go-ghdependency) will benefit from it.Feel free to share your thoughts! 🙏
Also mentioning other maintainers; @williammartin @andyfeller @BagToad
j-xella commentedon Aug 8, 2025
First, thanks for the detailed review. I have some questions:
I understand why command line parameters for each command are out of the question, but environment variables could be a bit of a pain to maintain in dynamically configurable environments... Could you consider the following approaches:
gh config set?gh auth login. And then they are used automatically while this authentication config is selected. Can this be used here as well?Does a new ticket have to be created in
cli/go-ghto proceed, or this discussion is enough?rnapier commentedon Aug 16, 2025
What's confusing me a bit is that as a Go tool, this should automatically support
SSL_CERT_FILE, but gh-cli doesn't seem to. Is this default behavior being intentionally disabled?kimusan commentedon Mar 27, 2026
Was a solution found for this? companies using Zscaler for security will not be able to use gh as it is rigth now
davidlovas commentedon Jun 21, 2026
Cross-posting from #13676 (closed as a dup) at @babakks's suggestion — adding the macOS/
trustdangle, which also answers @rnapier's question aboutSSL_CERT_FILE, since that's really the crux here.Why
SSL_CERT_FILEdoesn't "just work": on Linux, Go'scrypto/x509builds its roots from files and honorsSSL_CERT_FILE/SSL_CERT_DIR, so it works transparently. On macOS, whentls.Config.RootCAsis nil, Go defers verification to the system trust evaluator (Security.framework, backed by thetrustdmach service) rather than a file-based pool — so theSSL_CERT_FILEescape hatch that works on Linux isn't honored for the default verification path. Two failure modes fall out of this same gap:certificate signed by unknown authority(this issue: Zscaler, corporate CAs, GHE behind a private CA).trustdunreachable — in some sandboxed environments the mach service is blocked, so everyghHTTPS call fails with no way to supply a CA bundle.A small fix that covers both: at startup, if
SSL_CERT_FILE(or aGH_-prefixed variant) is set, load the PEM into anx509.CertPooland set it asRootCAson a clone ofhttp.DefaultTransport. A non-nilRootCAsforces Go's own pure-Go verifier, bypassingtrustdentirely. It's a no-op when unset, and since go-gh'sapi.NewHTTPClientbases its transport onhttp.DefaultTransport, every client (REST, GraphQL, auth) inherits it.We've been running this in a fork as a single ~40-line
init(): rexovasgroup#51. Happy to open a PR upstream if anSSL_CERT_FILE-based approach sounds acceptable.feat: Don't intercept developer tooling by default