Skip to content
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

Missing SSL_CTX_clear_mode and SSL_CTX_get_mode functions. #2347

Open
janis-ab opened this issue Jan 15, 2025 · 2 comments
Open

Missing SSL_CTX_clear_mode and SSL_CTX_get_mode functions. #2347

janis-ab opened this issue Jan 15, 2025 · 2 comments

Comments

@janis-ab
Copy link

In OpenSSL docs there are described SSL_CTX_clear_mode and SSL_CTX_get_mode functions.

It seems that library rust-openssl does not expose those functions. Is it possible to create bindings for them or other/newer functions should be used instead?

I see that https://docs.rs/openssl-sys/0.9.104/src/openssl_sys/ssl.rs.html#245-247 even SSL_CTX_set_mode does not use underlying OpenSSL's provided SSL_CTX_set_mode.

pub unsafe fn SSL_CTX_set_mode(ctx: *mut SSL_CTX, op: c_long) -> c_long {
    SSL_CTX_ctrl(ctx, SSL_CTRL_MODE, op, ptr::null_mut())
}

It SSL_CTX_ctrl docs there is comment:

These functions should never be called directly.

@janis-ab
Copy link
Author

And it is not possible to clear_mode with SSL_CTX_ctrl, because SSL_CTRL_CLEAR_MODE is not available as well.

@botovq
Copy link
Contributor

botovq commented Jan 15, 2025

It seems that library rust-openssl does not expose those functions

Those are not functions. Those are C preprocessor macros which are even more type unsafe than C generally is. These do what the rust-openssl reimplementation does:

# define SSL_CTX_set_mode(ctx,op) \
        SSL_CTX_ctrl((ctx),SSL_CTRL_MODE,(op),NULL)

Since Rust ffi ignores the C preprocessor you can't use the macros provided in ssl.h from Rust.

These functions should never be called directly.

The reason the OpenSSL docs say this is that you should be using the macro wrappers... which rust-openssl can't.

And it is not possible to clear_mode with SSL_CTX_ctrl, because SSL_CTRL_CLEAR_MODE is not available as well.

Well, that could be fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants