# Fix "AttributeError: module 'lib' has no attribute 'X509_V_FLAG_CB_ISSUER_CHECK'" From pyOpenSSL

Yes. An agent names the pyOpenSSL and cryptography pair behind the error, then drops or raises the pyOpenSSL pin and shows the failing import working again.

[Run this on Rush](https://cloud.getrush.ai/run/fix-x509-v-flag-cb-issuer-check-attribute-error/pyopenssl/). Opens the console with this prompt ready to send, in a Project that has your repository.

## What the agent does

`AttributeError: module 'lib' has no attribute 'X509_V_FLAG_CB_ISSUER_CHECK'` comes from the last lines of `OpenSSL/crypto.py`, and it means an old pyOpenSSL is installed beside a newer `cryptography`. pyOpenSSL is a thin layer over cryptography's OpenSSL bindings and reads constants from them when it is imported. Old pyOpenSSL releases accept any newer cryptography, and cryptography removes bindings as it goes, so a pin that was fine when it was written breaks later with no change to the project. The attribute in the message is only the first missing one, which is why searching for it leads to several similar reports.

foxpass/foxpass-ipsec-vpn is a clear case. Its nine-line `requirements.txt` pins `pyOpenSSL==19.1.0` and does not mention cryptography at all, so pip chooses the newest cryptography the interpreter allows. The `Dockerfile` (`FROM ubuntu:20.04`) and the Packer template `foxpass_vpn.json` both run `pip3 install -r` on that file. Installed into a clean environment, the pair fails on `import OpenSSL`, and the attribute named depends on what pip resolved: `X509_V_FLAG_CB_ISSUER_CHECK` with cryptography 38 through 41, `X509_V_FLAG_NOTIFY_POLICY` with 42 and with the 47.0.0 that Python 3.8 receives, and `GEN_EMAIL` with 50.0.2 on Python 3.11. It is one fault with three spellings.

The agent's first question is who imports pyOpenSSL, because nothing in this repository does. `scripts/config.py` imports `requests` at the top and `boto3` inside `gather_user_data_s3`, the function that reads the VPN's settings from an S3 URL. `import requests` succeeds. `import boto3` fails, and the traceback shows the path: `botocore/httpsession.py` imports `urllib3.contrib.pyopenssl`, which imports `OpenSSL`, which raises. So the broken package takes down an unrelated feature, and only on the code path that fetches configuration from S3. The agent reproduces exactly that import and keeps the traceback.

Then it picks between two fixes and tests both. Removing the pyOpenSSL line is the smaller one: with the package uninstalled, botocore falls back to the standard library's TLS and `import boto3` works. Raising the pin is the other: from pyOpenSSL 22.1.0 on, each release declares the cryptography range it supports, pip installs a matching pair, and the import works for 22.1.0, 23.x, 24.0.0 and 25.0.0. Releases 20.0.1, 21.0.0 and 22.0.0 still fail, so a small bump is not enough. The agent recommends removal when no code needs pyOpenSSL and the bump when something does, and it reads the second template, `gcp_foxpass_vpn.json`, which already removes the distribution's `python-openssl` package before installing: a sign the image has met this conflict before.

## Start it with one API call

`POST https://api.phoenix.so/o/{org}/sessions`

```json
{
  "agent": "claude",
  "input": "A Python process in this project fails with \"AttributeError: module 'lib' has no attribute 'X509_V_FLAG_CB_ISSUER_CHECK'\" (the attribute may instead be OpenSSL_add_all_algorithms, X509_V_FLAG_NOTIFY_POLICY or GEN_EMAIL; they are the same fault). The traceback ends in OpenSSL/crypto.py. Find where pyOpenSSL and cryptography versions come from: every requirements and constraints file, setup.py, pyproject.toml, lockfiles, Dockerfiles, image templates, provisioning scripts and CI, including OS packages such as python3-openssl. Find the Python version each of those environments uses. In a clean virtual environment on that Python, install the dependencies exactly as the project does, print the pyOpenSSL and cryptography versions that were resolved, and reproduce the error; keep the traceback. Then find what imports OpenSSL: search the project's code, and for each top-level import the project uses (requests, boto3, urllib3 and so on) run the import and record whether it fails and through which module. Choose the fix from the evidence. If nothing in the project or its dependencies needs pyOpenSSL, remove the pin and show the previously failing imports succeeding. If something needs it, raise the pin to a release that declares a compatible cryptography range (22.1.0 or later) and let pip resolve cryptography; do not add an old cryptography pin as the fix. Apply the same change everywhere dependencies are installed. Run the project's tests if it has any. Do not change unrelated pins; list any others that look stale. Open a pull request with the versions resolved before and after, the tracebacks, and which fix you chose and why.",
  "resources": [
    {
      "url": "https://github.com/your-org/your-app"
    }
  ]
}
```

1. **Get an API key.** In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
2. **Send the request.** POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
3. **Read what came back.** Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.

## What comes back

A pull request whose diff is usually one line in a requirements file, repeated wherever an image or script installs it. The description is where the value is. It states the two versions pip resolved, shows the failing import with its traceback, and names the module chain that led to `OpenSSL`, so a reader who never imports pyOpenSSL understands why their S3 call or HTTPS request died.

It then records the alternatives that were tried: which pyOpenSSL releases still fail, which import cleanly, and what happens with the package absent. That list is the argument for the chosen fix. If the agent kept pyOpenSSL, the description gives the cryptography version pip now selects beside it. If it removed the package, it names each import it re-ran to show nothing depended on it.

Before merging, a reviewer confirms the environments that matter were covered. An image built from a distribution can carry its own copy of pyOpenSSL or cryptography from an OS package, and pip may leave it in place. The pull request lists the install paths it found; anything provisioned outside the repository is for the reviewer to check.

## Run it on every failed image build

The natural trigger is the pipeline that builds the image or runs the provisioning script. Add a smoke test after dependencies are installed, a single `python3 -c "import OpenSSL"` or an import of your entry module, and a step that runs when it fails. That step sends the request above with your API key and the branch as the `resources` URL. Include a `request_id` that is a UUID v5 of the pipeline run id, so retries of the same build return the run that was already started.

Because the fault appears when cryptography publishes a release, not when you commit, a scheduled build finds it sooner than waiting for the next change. A nightly job on your side can run the same smoke test against a fresh install. If the key has a `webhook_url`, the `run.completed` event carries the agent's answer and a `session_url` for the full record.

## Why run it on Rush?

This is an error about what an installer resolves on a given day, so it has to be studied in an environment with nothing already installed. A workstation that has built a hundred virtualenvs tends to hold a cryptography version from months ago and will not reproduce it. The agent starts from an empty sandbox, installs the project's own file, and writes down what came out.

It also tests the candidate fixes instead of reasoning about them. Installing a series of pyOpenSSL releases and then no pyOpenSSL at all, and importing after each, is exactly the kind of loop people skip; in a run every attempt and its output is kept in the session transcript. The recommendation in the pull request can be checked against that record line by line.

## Frequently asked questions

### Why does the attribute name in my error differ from the one in the title?

The message names the first binding pyOpenSSL looks for and cannot find, and that depends on the cryptography version installed beside it. With pyOpenSSL 19.1.0 it is `X509_V_FLAG_CB_ISSUER_CHECK` for cryptography 38 to 41, `X509_V_FLAG_NOTIFY_POLICY` for 42 and 47, and `GEN_EMAIL` for 50. Reports that name `OpenSSL_add_all_algorithms` describe the same mismatch. The fix does not change.

### I never import OpenSSL. Why is my code failing?

A library imports it for you when it is installed. botocore tries `urllib3.contrib.pyopenssl` and catches only a missing package, so a broken pyOpenSSL raises through `import boto3`. The agent runs each of your top-level imports separately to find which ones are affected.

### Should I pin cryptography to an old version instead?

It works and it is the wrong direction. cryptography carries the OpenSSL build your TLS depends on, and holding it back to satisfy a 2019 wrapper means missing its security releases. Raise or remove pyOpenSSL and let pip choose a current cryptography.

### Is it safe to uninstall pyOpenSSL?

If nothing imports it, yes. Modern Python has the TLS features urllib3 once needed pyOpenSSL for, and in the example repository `import requests` and `import boto3` both work with the package removed. If your code calls `OpenSSL.crypto` or `OpenSSL.SSL` directly, keep it and raise the pin instead.

### Will upgrading pyOpenSSL alone be enough?

Only if you go far enough. Releases 20.0.1, 21.0.0 and 22.0.0 fail the same way against a current cryptography. From 22.1.0 on, each release states the cryptography versions it supports, so pip installs a pair that works together.

## More jobs like this: Fix a bug from an alert

- [Fix "XLRDError: Excel xlsx file; not supported" in a Python Project](https://getrush.ai/run/fix-xlrd-xlsx-not-supported/xlrd/)
- [Fix "load() missing 1 required positional argument: 'Loader'" in PyYAML](https://getrush.ai/run/fix-yaml-load-missing-loader/pyyaml/)
- [Replace PyCrypto With PyCryptodome in a Python Project](https://getrush.ai/run/migrate-pycrypto-to-pycryptodome/pycrypto/)
- [Fix openai.ChatCompletion Errors by Migrating to the v1 Client](https://getrush.ai/run/migrate-to-openai-v1/openai/)
- [Trim Message History in a LangGraph Agent](https://getrush.ai/run/trim-message-history/langgraph/)
- [Add Connection Pooling to a GORM App](https://getrush.ai/run/add-connection-pooling/gorm/)

## Keep reading

- [How a Rush run works on your repository, from request to pull request](https://getrush.ai/cloud/)
- [Compare cloud agents, agent sandboxes and AI code review](https://getrush.ai/compare/)
- [Rush pricing: Free, Pro and Max](https://getrush.ai/pricing/)
