`codex login` failed
What version of Codex is running?
codex-cli (rust) all versions
Which model were you using?
No response
What platform is your computer?
Darwin 24.5.0 arm64 arm
What steps can reproduce the bug?
codex login, then while call the callback URL after completing OpenAI's auth.
What is the expected behavior?
No response
What do you see instead?
In terminal:
Starting local login server on http://localhost:1455
If your browser did not open, navigate to this URL to authenticate:
https://auth.openai.com/oauth/authorize?response_type=...
Error logging in: login_with_chatgpt subprocess failed:
In browser: Error code 500. Message: Token exchange failed: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1000)>.
Additional information
- Tried
rm -rf ~/.codex. - Use
OPENAI_API_KEYinstead of paid ChatGPT login works fine. - Using http & https proxy.
I was able to reproduce the issue described. Unable to find any solution at the current time.
Same for me #1452
@MeowShe Try the NPM version instead of homebrew, Working for me #1099
@MeowShe Try the NPM version instead of homebrew, Working for me #1099
Thank you, @SuperstrongBE. I can confirm that the issue is present in Homebrew version, but not in the NPM one.
@SuperstrongBE @matt-novoselov Yes, the npm package works, but its latest tagged version is 0.1.2505172129, not 0.2.0; this seems to be a new issue introduced by the Rust version
Yes just realized that π
I have same error but on ssl.c:1018 not 1000
Error response
Error code: 500
Message: Token exchange failed: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1018)>.
Error code explanation: 500 - Server got itself in trouble.
Using brew or npm did not solve the issue.
I have same error but on ssl.c:1018 not 1000
Error response Error code: 500 Message: Token exchange failed: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1018)>. Error code explanation: 500 - Server got itself in trouble.Using brew or npm did not solve the issue.
Maybe it's because you're using 0.3.0?
I have same error but on ssl.c:1018 not 1000
Error response Error code: 500 Message: Token exchange failed: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1018)>. Error code explanation: 500 - Server got itself in trouble.Using brew or npm did not solve the issue.
Maybe it's because you're using
0.3.0?
I use 0.6.0 currently
Still happening in version 0.8.0 in both brew and npm versions for me (I tried installing it both ways)
Exact same error as the above.
These commands solved it for me: export SSL_CERT_FILE=$(python3 -m certifi) export REQUESTS_CA_BUNDLE=$(python3 -m certifi)
Then try "codex login" one more time
@thelonglincoln
Thx a ton, that helped! Still waiting for my "organization" authorization to come in (takes up to 15min, their errormessage says...)
It happens because of outdated python certs, you have to update the list of known CAs.
For me this worked
/Applications/Python\ 3.11/Install\ Certificates.command
Make sure you update with your python path and version.
ChatGPT Summary
β
Fix for codex login failing with SSL certificate verify error on macOS
If you're on macOS and get this error during codex login:
Token exchange failed: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1000)>
π Itβs likely caused by missing CA certificates in your Python environment.
β Solution (macOS, Python installed from python.org):
Run this in Terminal:
open /Applications/Python\ 3.11/Install\ Certificates.command
This installs the required root certificates that Python uses for SSL.
After that, codex login should work without SSL errors.
So now, we have confirmed that this is an issue caused by SSL certificate verification in Python.
@MeowShe did it resolve your issue?
I also executed codex login after installation of npm version and got this result:
konard@MacBook-Pro-Konstantin ~ % codex --version
codex-cli 0.10.0
http://localhost:1455/auth/callback?code=ac_GLaE3_cutkkyvb68UUZTOzlGanG_kZ8TfqUMJpdFe-c.e1290Qt-Nnd6V2o_SAJndzY3lt3ZZryo3E_njMIAP-o&scope=openid+profile+email+offline_access&state=909a9182a757654a482d1dbbd009ecff9ae79e70b6ab072157835e6a9279b008
Error response
Error code: 500
Message: Token exchange failed: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1000)>.
Error code explanation: 500 - Server got itself in trouble.
@MeowShe did it resolve your issue?
Yes, it works.
And I noticed that this is explicitly mentioned as something to do in the Python Installer but I never do it before haha
# install_certifi.py
#
# sample script to install or update a set of default Root Certificates
# for the ssl module. Uses the certificates provided by the certifi package:
# https://pypi.org/project/certifi/
import os
import os.path
import ssl
import stat
import subprocess
import sys
STAT_0o775 = ( stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR
| stat.S_IRGRP | stat.S_IWGRP | stat.S_IXGRP
| stat.S_IROTH | stat.S_IXOTH )
def main():
openssl_dir, openssl_cafile = os.path.split(
ssl.get_default_verify_paths().openssl_cafile)
print(" -- pip install --upgrade certifi")
subprocess.check_call([sys.executable,
"-E", "-s", "-m", "pip", "install", "--upgrade", "certifi"])
import certifi
# change working directory to the default SSL directory
os.chdir(openssl_dir)
relpath_to_certifi_cafile = os.path.relpath(certifi.where())
print(" -- removing any existing file or link")
try:
os.remove(openssl_cafile)
except FileNotFoundError:
pass
print(" -- creating symlink to certifi certificate bundle")
os.symlink(relpath_to_certifi_cafile, openssl_cafile)
print(" -- setting permissions")
os.chmod(openssl_cafile, STAT_0o775)
print(" -- update complete")
if __name__ == '__main__':
main()
export SSL_CERT_FILE=$(python3 -m certifi) export REQUESTS_CA_BUNDLE=$(python3 -m certifi)
Thank you, it works for me.
π Itβs likely caused by missing CA certificates in your Python environment.
β Solution (macOS, Python installed from python.org):
Run this in Terminal:
open /Applications/Python\ 3.11/Install\ Certificates.command
This installs the required root certificates that Python uses for SSL.
After that,
codex loginshould work without SSL errors.
This worked perfectly for me here. Thanks @alpha-adam Context - Installed via brew - Python 3.11.6
Fixed in 0.22.0. #2044