Skip to content

Source builds share system libcrypto with Python's ssl; libssh2 leaves OpenSSL errors on the queue after pubkey auth #246

Open

Description

@fruch

The manylinux wheels bundle a private libcrypto (ssh2_python.libs/), so they are isolated from the interpreter. A source build (e.g. on Python 3.15, where no wheel exists yet) links the system libcrypto, the same library Python's ssl module loads. Both then use one per-thread OpenSSL error queue.

During userauth_publickey_fromfile, libssh2 first tries OpenSSL's PEM decoder on an OpenSSH-format key. That fails with error:1E08010C:DECODER routines::unsupported; libssh2 then falls back to its own parser but never clears the error queue.

The next TLS read in the same thread (e.g. a pooled requests HTTPS connection) returns "want read", SSL_get_error() sees the stale error and reports SSL_ERROR_SSL, so ssl raises:

SSLError(1, '[OSSL_DECODER] unsupported (_ssl.c:3042)')

Seen with Python 3.15.2 / OpenSSL 3.5.7 on Debian trixie; with the cp314 wheel the queue is empty after auth.

Suggested fixes:

  • call ERR_clear_error() after libssh2 calls that can touch OpenSSL (at least the auth paths), so stale errors don't leak to other users of the library; and/or
  • document that source builds share libcrypto with the interpreter and recommend auditwheel repair.

Our workaround is auditwheel repair on the source build, which bundles a private libcrypto like the PyPI wheels: scylladb/scylla-cluster-tests#16742

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions