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

Mismatched Rust types at X509 bindings with BoringSSL on Windows 10 #2119

Closed
HMaker opened this issue Dec 6, 2023 · 7 comments
Closed

Mismatched Rust types at X509 bindings with BoringSSL on Windows 10 #2119

HMaker opened this issue Dec 6, 2023 · 7 comments

Comments

@HMaker
Copy link

HMaker commented Dec 6, 2023

I am getting the following compiler error when trying to link rust-openssl against BoringSSL (commit f78fe19fc98e0e6f760e05c6b9d48725004700d0, same from CI) on Windows 10:

D:\Users\heraldo\projects\rust-openssl>cargo build -r --package openssl
warning: expando.c
   Compiling openssl v0.10.61 (D:\Users\heraldo\projects\rust-openssl\openssl)
error[E0308]: mismatched types
   --> openssl\src\x509\mod.rs:764:62
    |
764 |                     if ffi::ERR_GET_LIB(err) as X509LenTy == ffi::ERR_LIB_PEM
    |                        ----------------------------------    ^^^^^^^^^^^^^^^^ expected `u32`, found `i32`
    |                        |
    |                        expected because this is `u32`
    |
help: you can convert an `i32` to a `u32` and panic if the converted value doesn't fit
    |
764 |                     if ffi::ERR_GET_LIB(err) as X509LenTy == ffi::ERR_LIB_PEM.try_into().unwrap()
    |                                                                              ++++++++++++++++++++

For more information about this error, try `rustc --explain E0308`.
error: could not compile `openssl` (lib) due to previous error

D:\Users\heraldo\projects\rust-openssl>

My Rust version is:

D:\Users\heraldo\projects\rust-openssl>rustc --version
rustc 1.73.0 (cc66ad468 2023-10-03)

D:\Users\heraldo\projects\rust-openssl>cargo --version
cargo 1.73.0 (9c4383fb5 2023-08-26)
@alex
Copy link
Collaborator

alex commented Dec 6, 2023

@sfackler do you remember why the cast is written in that strange way? Otherwise I'll probably just rewrite it to go via ErrorStack

@sfackler
Copy link
Owner

sfackler commented Dec 6, 2023

No, that cast seems suspicious to me as well.

@alex
Copy link
Collaborator

alex commented Dec 6, 2023

@HMaker can you verify if #2120 fixes it for you?

@alex alex closed this as completed in 3b38923 Dec 6, 2023
alex added a commit that referenced this issue Dec 6, 2023
fixes #2119 -- use ErrorStack abstraction in X.509 error handling
@HMaker
Copy link
Author

HMaker commented Dec 6, 2023

Now the openssl package builds, but when trying to build all packages I got the following compiler errors

error[E0432]: unresolved imports `openssl_sys::ERR_load_strings`, `openssl_sys::ERR_PACK`, `openssl_sys::ERR_STRING_DATA`
  --> openssl-errors\src\lib.rs:60:43
   |
60 |         init, ERR_get_next_error_library, ERR_load_strings, ERR_PACK, ERR_STRING_DATA,
   |                                           ^^^^^^^^^^^^^^^^  ^^^^^^^^  ^^^^^^^^^^^^^^^ no `ERR_STRING_DATA` in the root
   |                                           |                 |
   |                                           |                 no `ERR_PACK` in the root
   |                                           no `ERR_load_strings` in the root
   |
help: a similar name exists in the module
   |
60 |         init, ERR_get_next_error_library, ERR_load_BIO_strings, ERR_PACK, ERR_STRING_DATA,
   |                                           ~~~~~~~~~~~~~~~~~~~~
help: a similar name exists in the module
   |
60 |         init, ERR_get_next_error_library, ERR_load_strings, ERR_PACK, PEM_STRING_DSA,
   |                                                                       ~~~~~~~~~~~~~~

error[E0308]: mismatched types
    --> openssl-errors\src\lib.rs:169:17
     |
164  |             openssl_sys::ERR_put_error(
     |             -------------------------- arguments to this function are incorrect
...
169  |                 line as c_int,
     |                 ^^^^^^^^^^^^^ expected `u32`, found `i32`
     |
note: function defined here
    --> D:\Users\heraldo\projects\rust-openssl-alex\target\release\build\openssl-sys-dc144e27d7f73006\out/bindgen.rs:5298:12
     |
5298 |     pub fn ERR_put_error(
     |            ^^^^^^^^^^^^^
help: you can convert an `i32` to a `u32` and panic if the converted value doesn't fit
     |
169  |                 (line as c_int).try_into().unwrap(),
     |                 +             +++++++++++++++++++++

Some errors have detailed explanations: E0308, E0432.
For more information about an error, try `rustc --explain E0308`.
error: could not compile `openssl-errors` (lib) due to 2 previous errors
warning: build failed, waiting for other jobs to finish...

@alex
Copy link
Collaborator

alex commented Dec 6, 2023

The openssl-errors crate isn't supported on boringssl. What do you need it for?

@HMaker
Copy link
Author

HMaker commented Dec 6, 2023

I don't need it, I thought it was another compiler error. So it's fixed, thanks!

@alex
Copy link
Collaborator

alex commented Dec 6, 2023 via email

botovq added a commit to botovq/rust-openssl that referenced this issue Jan 11, 2024
Regression introduced in sfackler#2119. Ideally, tests would not leave
other errors behind.

Fixes sfackler#2146
botovq added a commit to botovq/rust-openssl that referenced this issue Jan 11, 2024
Regression introduced in sfackler#2119. Ideally, tests would not leave
other errors behind.

Fixes sfackler#2146
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

3 participants