-
-
Notifications
You must be signed in to change notification settings - Fork 752
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
Works under cargo test, but not when harness is executed directly? #575
Comments
Cargo does set some environment variables - LD_LIBRARY_PATH among them. Could be that it ends up pulling a different OpenSSL when run directly? There might also be places in the tests that are dependent on the working directory the test is run from, but I think I fixed all of those? |
I just checked, and there are definitely working directory issues but the errors caused there differ from what you're seeing. |
Are any working directory issues related to the certificate chain? |
Actually, the working dir should be the same in both cases. What about env vars? Also, "directly" is incorrect. The integration harness starts a server. The server (as a child process) is reporting the SSL failure when connecting to https://raw.github.com. But 'cargo test' makes the tests pass, and SSL work! |
Oh sorry, I was thinking you were talking about the tests in this crate. My best guess is that this is a case where the dynamic linker tracks down different copies of libssl in the two cases. OpenSSL contains a default certificate store path that's set at build time, and it could differ between the two copies. I'd probably add a bit of code to the integration test to dump the environment and look at what the differences are. |
From the harness, the differences when running under Cargo are:
Is OpenSSL on linux dynamically linked by default? |
Seems related: rust-lang/cargo#2888 |
We always prefer to dynamically link rather than statically link when possible, yeah. |
You can set |
Thanks! Any idea where SSL_CERT_DIR and SSL_CERT_FILE might be set? |
Assuming they aren't inherited from the shell, they could be leaking out of Cargo, which seems like a bug on its part - it could be setting them for libcurl? |
Setting them makes all the difference. |
Awesome! I filed a bug on Cargo about it leaking those variables to subprocesses: rust-lang/cargo#3676 |
Thanks. Any idea where to acquire good values for SSL_CERT_FILE and SSL_CERT_DIR, since it appears they are required? Or does system OpenSSL not need them? If system OpenSSL doesn't require them, has #565 landed in a release yet? If the link path issue is resolved I can go back to a system dynamic link (although I'd rather not). |
If those aren't set, OpenSSL will use defaults that were set when it was compiled. The system OpenSSL normally points the defaults to the right place, but presumably conan's version doesn't. Cargo uses https://crates.io/crates/openssl-probe to look in a bunch of common locations to track down the right paths. Ah yeah, I will cut a release today. |
i have the same issue, but use |
Verification fails without this, see sfackler/rust-openssl#575 CMK-14683 Change-Id: I4aa482af7cffb97e72126aca54d4f2a830f2439f
I'm seeing different behavior between cargo test and when I run one of my own test harnesses directly.
(Ssl(Failure(MidHandshakeSslStream { stream: SslStream { stream: HttpStream(_), ssl: Ssl { state: "error", verify_result: X509VerifyError { code: 20, error: "unable to get local issuer certificate" } } }, error: Ssl(ErrorStack([Error { code: 336134278, library: "SSL routines", function: "ssl3_get_server_certificate", reason: "certificate verify failed" }])) })))
Any environmental differences for me to look at?
The text was updated successfully, but these errors were encountered: