Skip to content

wolfssl-py: support disabling secure renegotiation #54

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,16 @@ wolfSSL library. For example:
# Uses custom install location
$ USE_LOCAL_WOLFSSL=/tmp/install pip install .

Disabling secure renegotiation
------------------------------

When building wolfssl-py from source secure renegotiation is enabled by
default. To disable secure renegotiation set the environment variable
WOLFSSLPY_DISABLE_SCR during the build process. For example:

.. code-block:: bash
$ WOLFSSLPY_DISABLE_SCR=1 pip install .

Testing
=======

Expand Down
5 changes: 4 additions & 1 deletion wolfssl/_build_ffi.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ def make_flags(prefix, debug):
"""
flags = []
cflags = []
# defaults to None (that eval to False)
disable_scr = os.getenv("WOLFSSLPY_DISABLE_SCR")

if get_platform() in ["linux-x86_64", "linux-i686"]:
cflags.append("-fpic")
Expand Down Expand Up @@ -171,7 +173,8 @@ def make_flags(prefix, debug):
cflags.append("-DKEEP_PEER_CERT")

# for pyOpenSSL
flags.append("--enable-secure-renegotiation")
if not disable_scr:
flags.append("--enable-secure-renegotiation")
flags.append("--enable-opensslall")
cflags.append("-DFP_MAX_BITS=8192")
cflags.append("-DHAVE_EX_DATA")
Expand Down
9 changes: 8 additions & 1 deletion wolfssl/_openssl.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA

# pylint: disable=missing-docstring, invalid-name
import os

source = """
#include <wolfssl/options.h>
Expand Down Expand Up @@ -248,7 +249,6 @@ def construct_cdef(optional_funcs, OLDTLS_ENABLED):
X509* SSL_get_peer_certificate(SSL*);
const char* SSL_alert_type_string_long(int);
const char* SSL_alert_desc_string_long(int);
int SSL_renegotiate(SSL*);
void SSL_get0_next_proto_negotiated(const SSL*,
const unsigned char**, unsigned*);
const char* SSL_get_servername(SSL*, unsigned char);
Expand Down Expand Up @@ -306,6 +306,13 @@ def construct_cdef(optional_funcs, OLDTLS_ENABLED):
int OBJ_txt2nid(const char*);
"""

# defaults to None (that eval to False)
disable_scr = os.getenv("WOLFSSLPY_DISABLE_SCR")
if not disable_scr:
cdef += """
int SSL_renegotiate(SSL*);
"""

for func in optional_funcs:
cdef += "{};".format(func.ossl_sig)

Expand Down
Loading